Skip to content

Commit 05cb8a5

Browse files
committed
feat(cms): implement reusable content pattern
closed COD-294
1 parent 789dc78 commit 05cb8a5

19 files changed

Lines changed: 9670 additions & 20 deletions

File tree

apps/cms/src/app/(frontend)/globals.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@import 'tailwindcss';
22

3+
/* Custom Tailwind css for Payload CMS */
4+
@import '../../../../../libs/shared/util/tailwind/src/lib/payload.css';
5+
36
/* Let Tailwind know about the shadcn components */
47
@source '../../../../../libs/shared/ui';
58

apps/cms/src/collections/cards/cards.collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const env = getEnv();
99

1010
/**
1111
* Cards collection where one or many reusable cards can be created
12+
* @deprecated use reusable-content instead
1213
*/
1314
const cards: CollectionConfig = {
1415
slug: 'cards',

apps/cms/src/collections/pages/pages.collection.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ const pages: CollectionConfig<'pages'> = {
5050
{
5151
type: 'tabs',
5252
tabs: [
53-
// TODO: Maybe here or as a block
54-
// {
55-
// label: 'Hero',
56-
// fields: []
57-
// },
5853
{
5954
label: { en: 'Content', sv: 'Innehåll' },
6055
fields: [
@@ -76,7 +71,14 @@ const pages: CollectionConfig<'pages'> = {
7671
name: 'layout',
7772
type: 'blocks',
7873
label: 'Layout builder',
79-
blockReferences: ['content', 'card', 'form', 'media', 'code'],
74+
blockReferences: [
75+
'content',
76+
'card',
77+
'form',
78+
'media',
79+
'code',
80+
'reusable-content'
81+
],
8082
blocks: [],
8183
required: true,
8284
localized: true,

apps/cms/src/collections/posts/posts.collection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ const posts: CollectionConfig<'posts'> = {
6969
HeadingFeature({
7070
enabledHeadingSizes: ['h1', 'h2', 'h3', 'h4']
7171
}),
72-
BlocksFeature({ blocks: ['card', 'code', 'media'] })
72+
BlocksFeature({
73+
blocks: ['card', 'code', 'media', 'reusable-content']
74+
})
7375
]
7476
}),
7577
label: false,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { CollectionConfig } from 'payload';
2+
3+
import { getEnv } from '@codeware/app-cms/feature/env-loader';
4+
import { verifyApiKeyAccess } from '@codeware/app-cms/util/access';
5+
import { adminGroups } from '@codeware/app-cms/util/definitions';
6+
7+
const env = getEnv();
8+
9+
/**
10+
* Reusable content collection
11+
*/
12+
const reusableContent: CollectionConfig = {
13+
slug: 'reusable-content',
14+
access: {
15+
read: verifyApiKeyAccess({ secret: env.SIGNATURE_SECRET })
16+
},
17+
admin: {
18+
group: adminGroups.content,
19+
useAsTitle: 'title',
20+
description: {
21+
en: 'Reusable content is a collection of blocks that can be combined freely and used in various places.',
22+
sv: 'Återanvändbara element är en samling block som kan kombineras fritt och användas på olika ställen.'
23+
}
24+
},
25+
labels: {
26+
plural: { en: 'Reusable Contents', sv: 'Återanvändbara element' },
27+
singular: { en: 'Reusable Content', sv: 'Återanvändbart element' }
28+
},
29+
fields: [
30+
{
31+
name: 'title',
32+
label: { en: 'Title', sv: 'Titel' },
33+
type: 'text',
34+
required: true,
35+
localized: true,
36+
admin: {
37+
description: {
38+
en: 'What is the reusable content about?',
39+
sv: 'Vad handlar det återanvändbara elementet om?'
40+
}
41+
}
42+
},
43+
{
44+
name: 'layout',
45+
type: 'blocks',
46+
blockReferences: ['card', 'code', 'content', 'form', 'media'],
47+
blocks: [],
48+
required: true
49+
}
50+
]
51+
};
52+
53+
export default reusableContent;

0 commit comments

Comments
 (0)