Skip to content

Commit c39e3c2

Browse files
committed
Add news component and content types
1 parent 2257a42 commit c39e3c2

File tree

6 files changed

+94
-51
lines changed

6 files changed

+94
-51
lines changed

templates/alloy-template/src/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Editorial, { EditorialContentType } from '@/components/base/Editorial';
1414
import Contact, { ContactContentType } from '@/components/base/Contact';
1515
import StartPage, { StartPageContentType } from '@/components/Start';
1616
import Product, { ProductContentType } from '@/components/Product';
17-
import StandardPage, { StandardContentType } from '@/components/Standard';
17+
import Standard, { StandardContentType } from '@/components/Standard';
1818
import Notice, { NoticeContentType } from '@/components/base/Notice';
1919
import News, { NewsContentType } from '@/components/News';
2020
import Article, { ArticleContentType } from '@/components/base/Article';
@@ -56,7 +56,7 @@ initReactComponentRegistry({
5656
News,
5757
Notice,
5858
Product,
59-
StandardPage,
59+
Standard,
6060
StartPage,
6161
Teaser,
6262
BlankSection,

templates/alloy-template/src/components/News.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,42 @@ export const NewsContentType = contentType({
1313
baseType: '_experience',
1414
mayContainTypes: [StandardContentType],
1515
properties: {
16-
teaser_image: {
16+
image: {
1717
type: 'contentReference',
1818
displayName: 'Teaser Image',
1919
},
20-
teaser_text: {
20+
title: {
2121
type: 'string',
2222
displayName: 'Teaser Text',
2323
},
24+
description: {
25+
type: 'string',
26+
displayName: 'Description',
27+
},
2428
main_body: {
2529
type: 'richText',
2630
displayName: 'Main Body',
2731
},
28-
title: {
29-
type: 'string',
30-
},
31-
keywords: {
32-
type: 'string',
33-
},
34-
page_description: {
35-
type: 'string',
36-
},
3732
},
3833
});
3934

40-
type StandardPageProps = {
41-
opti: Infer<typeof StandardContentType>;
35+
type NewsPageProps = {
36+
opti: Infer<typeof NewsContentType>;
4237
};
4338

4439
function ComponentWrapper({ children, node }: ComponentContainerProps) {
4540
const { pa } = getPreviewUtils(node);
4641
return <div {...pa(node)}>{children}</div>;
4742
}
4843

49-
function StandardPage({ opti }: StandardPageProps) {
44+
function News({ opti }: NewsPageProps) {
5045
return (
5146
<div>
5247
<h2>{opti.title}</h2>
53-
<p>{opti.teaser_text}</p>
48+
<p>{opti.description}</p>
5449
<div>
55-
{opti.teaser_image?.url.default && (
56-
<img src={opti.teaser_image.url.default} alt={'Teaser Image'} />
50+
{opti.image?.url.default && (
51+
<img src={opti.image.url.default} alt={'Teaser Image'} />
5752
)}
5853
</div>
5954
<RichText content={opti.main_body?.json} />
@@ -65,4 +60,4 @@ function StandardPage({ opti }: StandardPageProps) {
6560
);
6661
}
6762

68-
export default StandardPage;
63+
export default News;

templates/alloy-template/src/components/Standard.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,25 @@ export const StandardContentType = contentType({
1010
key: 'Standard',
1111
displayName: 'Standard Page',
1212
baseType: '_experience',
13-
mayContainTypes: ['_self'],
13+
mayContainTypes: ['_self', 'News'],
1414
properties: {
15-
teaser_image: {
15+
image: {
1616
type: 'contentReference',
1717
allowedTypes: ['_image'],
1818
displayName: 'Teaser Image',
1919
},
20-
teaser_text: {
20+
heading: {
2121
type: 'string',
2222
displayName: 'Teaser Text',
2323
},
24+
description: {
25+
type: 'string',
26+
displayName: 'Description',
27+
},
2428
main_body: {
2529
type: 'richText',
2630
displayName: 'Main Body',
2731
},
28-
title: {
29-
type: 'string',
30-
},
31-
keywords: {
32-
type: 'string',
33-
},
34-
page_description: {
35-
type: 'string',
36-
},
3732
},
3833
});
3934

@@ -46,14 +41,14 @@ function ComponentWrapper({ children, node }: ComponentContainerProps) {
4641
return <div {...pa(node)}>{children}</div>;
4742
}
4843

49-
function StandardPage({ opti }: StandardPageProps) {
44+
function Standard({ opti }: StandardPageProps) {
5045
return (
5146
<div>
52-
<h2>{opti.title}</h2>
53-
<p>{opti.teaser_text}</p>
47+
<h1 className="text-3xl font-bold">{opti.heading}</h1>
48+
<p>{opti.description}</p>
5449
<div>
55-
{opti.teaser_image?.url.default && (
56-
<img src={opti.teaser_image.url.default} alt={'Teaser Image'} />
50+
{opti.image?.url.default && (
51+
<img src={opti.image.url.default} alt={'Teaser Image'} />
5752
)}
5853
</div>
5954
<RichText content={opti.main_body?.json} />
@@ -65,4 +60,4 @@ function StandardPage({ opti }: StandardPageProps) {
6560
);
6661
}
6762

68-
export default StandardPage;
63+
export default Standard;

templates/alloy-template/src/components/base/Footer.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@ const defaultSections: FooterSection[] = [
1616
{
1717
title: 'PRODUCTS',
1818
links: [
19-
{ label: 'Alloy Plan', href: '/alloy-plan' },
20-
{ label: 'Alloy Track', href: '/alloy-track' },
21-
{ label: 'Alloy Meet', href: '/alloy-meet' },
19+
{ label: 'Alloy Plan', href: '/en/alloy-plan' },
20+
{ label: 'Alloy Track', href: '/en/alloy-track' },
21+
{ label: 'Alloy Meet', href: '/en/alloy-meet' },
2222
],
2323
},
2424
{
2525
title: 'THE COMPANY',
2626
links: [
27-
{ label: 'History', href: '/history' },
28-
{ label: 'News & Events', href: '/news' },
29-
{ label: 'Management', href: '/management' },
30-
{ label: 'Contact us', href: '/contact' },
31-
{ label: 'Become a reseller', href: '/reseller' },
27+
{ label: 'History', href: '/en/history' },
28+
{ label: 'News & Events', href: '/en/news' },
29+
{ label: 'Management', href: '/en/management' },
30+
{ label: 'Contact us', href: '/en/contact' },
31+
{ label: 'Become a reseller', href: '/en/reseller' },
3232
],
3333
},
3434
{
3535
title: 'NEWS & EVENTS',
3636
links: [
37-
{ label: 'Events', href: '/events' },
38-
{ label: 'Press Releases', href: '/press' },
37+
{ label: 'Events', href: '/en/events' },
38+
{ label: 'Press Releases', href: '/en/press' },
3939
],
4040
},
4141
{
4242
title: 'CUSTOMER ZONE',
4343
links: [
44-
{ label: 'Reseller extranet', href: '/reseller-extranet' },
45-
{ label: 'Log out', href: '/logout' },
44+
{ label: 'Reseller extranet', href: '/en/reseller-extranet' },
45+
{ label: 'Log out', href: '/en/logout' },
4646
],
4747
},
4848
];

templates/alloy-template/src/components/base/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const defaultNavigationItems: NavigationItem[] = [
1212
{ label: 'ALLOY PLAN', href: '/en/alloy-plan' },
1313
{ label: 'ALLOY TRACK', href: '/en/alloy-track' },
1414
{ label: 'ALLOY MEET', href: '/en/alloy-meet' },
15-
{ label: 'ABOUT US', href: '/about' },
15+
{ label: 'ABOUT US', href: '/en/about-us' },
1616
];
1717

1818
function Header({ navigationItems = defaultNavigationItems }: HeaderProps) {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { contentType } from '@optimizely/cms-sdk';
2+
3+
const PageList = contentType({
4+
key: 'PageListBlock',
5+
displayName: '',
6+
description: '',
7+
baseType: '_component',
8+
properties: {
9+
Heading: {
10+
type: 'string',
11+
displayName: 'Heading',
12+
},
13+
IncludePublishDate: {
14+
type: 'boolean',
15+
displayName: 'IncludePublishDate',
16+
},
17+
IncludeIntroduction: {
18+
type: 'boolean',
19+
displayName: 'IncludeIntroduction',
20+
},
21+
Count: {
22+
type: 'integer',
23+
displayName: 'Count',
24+
},
25+
SortOrder: {
26+
type: 'integer',
27+
displayName: 'SortOrder',
28+
},
29+
Root: {
30+
type: 'contentReference',
31+
format: 'PageReference',
32+
displayName: 'Root',
33+
restrictedTypes: [],
34+
},
35+
PageTypeFilter: {
36+
type: 'string',
37+
format: 'PageType',
38+
displayName: 'PageTypeFilter',
39+
},
40+
CategoryFilter: {
41+
type: 'array',
42+
format: 'categorization',
43+
displayName: 'CategoryFilter',
44+
items: {
45+
type: 'integer',
46+
},
47+
},
48+
Recursive: {
49+
type: 'boolean',
50+
displayName: 'Recursive',
51+
},
52+
},
53+
});

0 commit comments

Comments
 (0)