@duffcloudservices/cms 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,309 +1,309 @@
1
- # @duffcloudservices/cms
2
-
3
- Vue 3 composables and Vite plugins for DCS (Duff Cloud Services) CMS integration.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- # Using pnpm
9
- pnpm add @duffcloudservices/cms
10
-
11
- # Using npm
12
- npm install @duffcloudservices/cms
13
-
14
- # Using yarn
15
- yarn add @duffcloudservices/cms
16
- ```
17
-
18
- ### Peer Dependencies
19
-
20
- This package requires:
21
- - `vue` ^3.4.0
22
- - `@unhead/vue` ^1.9.0
23
-
24
- ## Quick Start
25
-
26
- ### 1. Configure Vite Plugins
27
-
28
- ```typescript
29
- // vite.config.ts
30
- import { defineConfig } from 'vite'
31
- import vue from '@vitejs/plugin-vue'
32
- import { dcsContentPlugin, dcsSeoPlugin } from '@duffcloudservices/cms/plugins'
33
-
34
- export default defineConfig({
35
- plugins: [
36
- vue(),
37
- dcsContentPlugin(),
38
- dcsSeoPlugin()
39
- ]
40
- })
41
- ```
42
-
43
- For VitePress:
44
-
45
- ```typescript
46
- // .vitepress/config.ts
47
- import { defineConfig } from 'vitepress'
48
- import { dcsContentPlugin, dcsSeoPlugin } from '@duffcloudservices/cms/plugins'
49
-
50
- export default defineConfig({
51
- vite: {
52
- plugins: [
53
- dcsContentPlugin(),
54
- dcsSeoPlugin()
55
- ]
56
- }
57
- })
58
- ```
59
-
60
- ### 2. Set Environment Variables
61
-
62
- ```bash
63
- # .env
64
- VITE_SITE_SLUG=your-site-slug
65
-
66
- # Optional: for runtime overrides (premium tier)
67
- VITE_API_BASE_URL=https://portal.duffcloudservices.com
68
- VITE_TEXT_OVERRIDE_MODE=commit # 'commit' (default) or 'runtime'
69
- ```
70
-
71
- ### 3. Use Composables
72
-
73
- ```vue
74
- <script setup lang="ts">
75
- import { useTextContent, useSEO } from '@duffcloudservices/cms'
76
-
77
- // Text content with defaults
78
- const { t } = useTextContent({
79
- pageSlug: 'home',
80
- defaults: {
81
- 'hero.title': 'Welcome to Our Site',
82
- 'hero.subtitle': 'Build amazing things with us',
83
- 'cta.primary': 'Get Started'
84
- }
85
- })
86
-
87
- // SEO configuration
88
- const { applyHead } = useSEO('home')
89
- applyHead()
90
- </script>
91
-
92
- <template>
93
- <section class="hero">
94
- <h1>{{ t('hero.title') }}</h1>
95
- <p>{{ t('hero.subtitle') }}</p>
96
- <button>{{ t('cta.primary') }}</button>
97
- </section>
98
- </template>
99
- ```
100
-
101
- ## Composables
102
-
103
- ### useTextContent
104
-
105
- Provides text content management with build-time injection and optional runtime overrides.
106
-
107
- ```typescript
108
- import { useTextContent } from '@duffcloudservices/cms'
109
-
110
- const {
111
- t, // (key: string, fallback?: string) => string
112
- texts, // ComputedRef<Record<string, string>>
113
- overrides, // Ref<Record<string, string>>
114
- isLoading, // Ref<boolean>
115
- error, // Ref<string | null>
116
- refresh, // () => Promise<void>
117
- hasOverride, // (key: string) => boolean
118
- hasBuildTimeContent, // boolean
119
- mode // 'commit' | 'runtime'
120
- } = useTextContent({
121
- pageSlug: 'home',
122
- defaults: {
123
- 'hero.title': 'Default Title'
124
- },
125
- fetchOnMount: true, // default: true (only matters in runtime mode)
126
- cacheTtl: 60000 // default: 60000ms
127
- })
128
- ```
129
-
130
- **Content Resolution Order:**
131
- 1. Runtime API overrides (premium tier only)
132
- 2. Build-time content from `.dcs/content.yaml`
133
- 3. Hardcoded defaults passed to the composable
134
-
135
- ### useSEO
136
-
137
- Provides SEO configuration with meta tags, Open Graph, Twitter Cards, and JSON-LD.
138
-
139
- ```typescript
140
- import { useSEO } from '@duffcloudservices/cms'
141
-
142
- const {
143
- config, // ComputedRef<ResolvedPageSeo>
144
- applyHead, // (overrides?: HeadOverrides) => void
145
- getSchema, // () => object[]
146
- getCanonical, // () => string
147
- hasBuildTimeSeo // boolean
148
- } = useSEO('home', '/') // pageSlug, optional pagePath
149
-
150
- // Apply all meta tags
151
- applyHead()
152
-
153
- // Or with overrides
154
- applyHead({
155
- title: 'Custom Title',
156
- description: 'Custom description',
157
- schemas: [...getSchema(), customSchema]
158
- })
159
- ```
160
-
161
- ### useReleaseNotes
162
-
163
- Fetches release notes from the DCS Portal API.
164
-
165
- ```typescript
166
- import { useReleaseNotes } from '@duffcloudservices/cms'
167
-
168
- const {
169
- releaseNote, // Ref<ReleaseNote | null>
170
- isLoading, // Ref<boolean>
171
- error, // Ref<string | null>
172
- refresh // () => Promise<void>
173
- } = useReleaseNotes('1.2.0') // or 'latest'
174
- ```
175
-
176
- ### useSiteVersion
177
-
178
- Gets the current site version for footer badges.
179
-
180
- ```typescript
181
- import { useSiteVersion } from '@duffcloudservices/cms'
182
-
183
- const {
184
- version, // Ref<string | null>
185
- isLoading, // Ref<boolean>
186
- releaseNotesUrl // ComputedRef<string>
187
- } = useSiteVersion()
188
- ```
189
-
190
- ## Vite Plugins
191
-
192
- ### dcsContentPlugin
193
-
194
- Injects `.dcs/content.yaml` at build time.
195
-
196
- ```typescript
197
- import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'
198
-
199
- dcsContentPlugin({
200
- contentPath: '.dcs/content.yaml', // default
201
- debug: false // default
202
- })
203
- ```
204
-
205
- ### dcsSeoPlugin
206
-
207
- Injects `.dcs/seo.yaml` at build time.
208
-
209
- ```typescript
210
- import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'
211
-
212
- dcsSeoPlugin({
213
- seoPath: '.dcs/seo.yaml', // default
214
- debug: false // default
215
- })
216
- ```
217
-
218
- ## Configuration Files
219
-
220
- ### .dcs/content.yaml
221
-
222
- ```yaml
223
- version: 1
224
- lastUpdated: "2025-01-01T00:00:00Z"
225
- updatedBy: "portal"
226
-
227
- global:
228
- nav.home: Home
229
- nav.about: About
230
- footer.copyright: © 2025 My Company
231
-
232
- pages:
233
- home:
234
- hero.title: Welcome to Our Site
235
- hero.subtitle: Build amazing things
236
- cta.primary: Get Started
237
- about:
238
- hero.title: About Us
239
- hero.subtitle: Learn more about our mission
240
- ```
241
-
242
- ### .dcs/seo.yaml
243
-
244
- ```yaml
245
- version: 1
246
- lastUpdated: "2025-01-01T00:00:00Z"
247
-
248
- global:
249
- siteName: My Site
250
- siteUrl: https://example.com
251
- locale: en_US
252
- defaultTitle: My Site
253
- defaultDescription: Build amazing things with us
254
- titleTemplate: "%s | My Site"
255
-
256
- social:
257
- twitter: mycompany
258
- linkedin: my-company
259
-
260
- images:
261
- logo: https://example.com/logo.png
262
- ogDefault: https://example.com/og-image.jpg
263
-
264
- pages:
265
- home:
266
- title: Welcome
267
- description: Build amazing things with our platform
268
- noTitleTemplate: true
269
- openGraph:
270
- type: website
271
- twitter:
272
- card: summary_large_image
273
-
274
- about:
275
- title: About Us
276
- description: Learn more about our company and mission
277
- ```
278
-
279
- ## TypeScript Support
280
-
281
- All composables and plugins are fully typed. Import types as needed:
282
-
283
- ```typescript
284
- import type {
285
- TextContentConfig,
286
- TextContentReturn,
287
- SeoConfiguration,
288
- PageSeoConfig,
289
- ReleaseNote
290
- } from '@duffcloudservices/cms'
291
- ```
292
-
293
- ## Migration from Manual Setup
294
-
295
- If you're migrating from manually copied composables:
296
-
297
- ```typescript
298
- // Before:
299
- import { useTextContent } from '@/lib/use-text-content'
300
-
301
- // After:
302
- import { useTextContent } from '@duffcloudservices/cms'
303
- ```
304
-
305
- The API is the same, so no other code changes are needed.
306
-
307
- ## License
308
-
309
- MIT
1
+ # @duffcloudservices/cms
2
+
3
+ Vue 3 composables and Vite plugins for DCS (Duff Cloud Services) CMS integration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Using pnpm
9
+ pnpm add @duffcloudservices/cms
10
+
11
+ # Using npm
12
+ npm install @duffcloudservices/cms
13
+
14
+ # Using yarn
15
+ yarn add @duffcloudservices/cms
16
+ ```
17
+
18
+ ### Peer Dependencies
19
+
20
+ This package requires:
21
+ - `vue` ^3.4.0
22
+ - `@unhead/vue` ^1.9.0
23
+
24
+ ## Quick Start
25
+
26
+ ### 1. Configure Vite Plugins
27
+
28
+ ```typescript
29
+ // vite.config.ts
30
+ import { defineConfig } from 'vite'
31
+ import vue from '@vitejs/plugin-vue'
32
+ import { dcsContentPlugin, dcsSeoPlugin } from '@duffcloudservices/cms/plugins'
33
+
34
+ export default defineConfig({
35
+ plugins: [
36
+ vue(),
37
+ dcsContentPlugin(),
38
+ dcsSeoPlugin()
39
+ ]
40
+ })
41
+ ```
42
+
43
+ For VitePress:
44
+
45
+ ```typescript
46
+ // .vitepress/config.ts
47
+ import { defineConfig } from 'vitepress'
48
+ import { dcsContentPlugin, dcsSeoPlugin } from '@duffcloudservices/cms/plugins'
49
+
50
+ export default defineConfig({
51
+ vite: {
52
+ plugins: [
53
+ dcsContentPlugin(),
54
+ dcsSeoPlugin()
55
+ ]
56
+ }
57
+ })
58
+ ```
59
+
60
+ ### 2. Set Environment Variables
61
+
62
+ ```bash
63
+ # .env
64
+ VITE_SITE_SLUG=your-site-slug
65
+
66
+ # Optional: for runtime overrides (premium tier)
67
+ VITE_API_BASE_URL=https://portal.duffcloudservices.com
68
+ VITE_TEXT_OVERRIDE_MODE=commit # 'commit' (default) or 'runtime'
69
+ ```
70
+
71
+ ### 3. Use Composables
72
+
73
+ ```vue
74
+ <script setup lang="ts">
75
+ import { useTextContent, useSEO } from '@duffcloudservices/cms'
76
+
77
+ // Text content with defaults
78
+ const { t } = useTextContent({
79
+ pageSlug: 'home',
80
+ defaults: {
81
+ 'hero.title': 'Welcome to Our Site',
82
+ 'hero.subtitle': 'Build amazing things with us',
83
+ 'cta.primary': 'Get Started'
84
+ }
85
+ })
86
+
87
+ // SEO configuration
88
+ const { applyHead } = useSEO('home')
89
+ applyHead()
90
+ </script>
91
+
92
+ <template>
93
+ <section class="hero">
94
+ <h1>{{ t('hero.title') }}</h1>
95
+ <p>{{ t('hero.subtitle') }}</p>
96
+ <button>{{ t('cta.primary') }}</button>
97
+ </section>
98
+ </template>
99
+ ```
100
+
101
+ ## Composables
102
+
103
+ ### useTextContent
104
+
105
+ Provides text content management with build-time injection and optional runtime overrides.
106
+
107
+ ```typescript
108
+ import { useTextContent } from '@duffcloudservices/cms'
109
+
110
+ const {
111
+ t, // (key: string, fallback?: string) => string
112
+ texts, // ComputedRef<Record<string, string>>
113
+ overrides, // Ref<Record<string, string>>
114
+ isLoading, // Ref<boolean>
115
+ error, // Ref<string | null>
116
+ refresh, // () => Promise<void>
117
+ hasOverride, // (key: string) => boolean
118
+ hasBuildTimeContent, // boolean
119
+ mode // 'commit' | 'runtime'
120
+ } = useTextContent({
121
+ pageSlug: 'home',
122
+ defaults: {
123
+ 'hero.title': 'Default Title'
124
+ },
125
+ fetchOnMount: true, // default: true (only matters in runtime mode)
126
+ cacheTtl: 60000 // default: 60000ms
127
+ })
128
+ ```
129
+
130
+ **Content Resolution Order:**
131
+ 1. Runtime API overrides (premium tier only)
132
+ 2. Build-time content from `.dcs/content.yaml`
133
+ 3. Hardcoded defaults passed to the composable
134
+
135
+ ### useSEO
136
+
137
+ Provides SEO configuration with meta tags, Open Graph, Twitter Cards, and JSON-LD.
138
+
139
+ ```typescript
140
+ import { useSEO } from '@duffcloudservices/cms'
141
+
142
+ const {
143
+ config, // ComputedRef<ResolvedPageSeo>
144
+ applyHead, // (overrides?: HeadOverrides) => void
145
+ getSchema, // () => object[]
146
+ getCanonical, // () => string
147
+ hasBuildTimeSeo // boolean
148
+ } = useSEO('home', '/') // pageSlug, optional pagePath
149
+
150
+ // Apply all meta tags
151
+ applyHead()
152
+
153
+ // Or with overrides
154
+ applyHead({
155
+ title: 'Custom Title',
156
+ description: 'Custom description',
157
+ schemas: [...getSchema(), customSchema]
158
+ })
159
+ ```
160
+
161
+ ### useReleaseNotes
162
+
163
+ Fetches release notes from the DCS Portal API.
164
+
165
+ ```typescript
166
+ import { useReleaseNotes } from '@duffcloudservices/cms'
167
+
168
+ const {
169
+ releaseNote, // Ref<ReleaseNote | null>
170
+ isLoading, // Ref<boolean>
171
+ error, // Ref<string | null>
172
+ refresh // () => Promise<void>
173
+ } = useReleaseNotes('1.2.0') // or 'latest'
174
+ ```
175
+
176
+ ### useSiteVersion
177
+
178
+ Gets the current site version for footer badges.
179
+
180
+ ```typescript
181
+ import { useSiteVersion } from '@duffcloudservices/cms'
182
+
183
+ const {
184
+ version, // Ref<string | null>
185
+ isLoading, // Ref<boolean>
186
+ releaseNotesUrl // ComputedRef<string>
187
+ } = useSiteVersion()
188
+ ```
189
+
190
+ ## Vite Plugins
191
+
192
+ ### dcsContentPlugin
193
+
194
+ Injects `.dcs/content.yaml` at build time.
195
+
196
+ ```typescript
197
+ import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'
198
+
199
+ dcsContentPlugin({
200
+ contentPath: '.dcs/content.yaml', // default
201
+ debug: false // default
202
+ })
203
+ ```
204
+
205
+ ### dcsSeoPlugin
206
+
207
+ Injects `.dcs/seo.yaml` at build time.
208
+
209
+ ```typescript
210
+ import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'
211
+
212
+ dcsSeoPlugin({
213
+ seoPath: '.dcs/seo.yaml', // default
214
+ debug: false // default
215
+ })
216
+ ```
217
+
218
+ ## Configuration Files
219
+
220
+ ### .dcs/content.yaml
221
+
222
+ ```yaml
223
+ version: 1
224
+ lastUpdated: "2025-01-01T00:00:00Z"
225
+ updatedBy: "portal"
226
+
227
+ global:
228
+ nav.home: Home
229
+ nav.about: About
230
+ footer.copyright: © 2025 My Company
231
+
232
+ pages:
233
+ home:
234
+ hero.title: Welcome to Our Site
235
+ hero.subtitle: Build amazing things
236
+ cta.primary: Get Started
237
+ about:
238
+ hero.title: About Us
239
+ hero.subtitle: Learn more about our mission
240
+ ```
241
+
242
+ ### .dcs/seo.yaml
243
+
244
+ ```yaml
245
+ version: 1
246
+ lastUpdated: "2025-01-01T00:00:00Z"
247
+
248
+ global:
249
+ siteName: My Site
250
+ siteUrl: https://example.com
251
+ locale: en_US
252
+ defaultTitle: My Site
253
+ defaultDescription: Build amazing things with us
254
+ titleTemplate: "%s | My Site"
255
+
256
+ social:
257
+ twitter: mycompany
258
+ linkedin: my-company
259
+
260
+ images:
261
+ logo: https://example.com/logo.png
262
+ ogDefault: https://example.com/og-image.jpg
263
+
264
+ pages:
265
+ home:
266
+ title: Welcome
267
+ description: Build amazing things with our platform
268
+ noTitleTemplate: true
269
+ openGraph:
270
+ type: website
271
+ twitter:
272
+ card: summary_large_image
273
+
274
+ about:
275
+ title: About Us
276
+ description: Learn more about our company and mission
277
+ ```
278
+
279
+ ## TypeScript Support
280
+
281
+ All composables and plugins are fully typed. Import types as needed:
282
+
283
+ ```typescript
284
+ import type {
285
+ TextContentConfig,
286
+ TextContentReturn,
287
+ SeoConfiguration,
288
+ PageSeoConfig,
289
+ ReleaseNote
290
+ } from '@duffcloudservices/cms'
291
+ ```
292
+
293
+ ## Migration from Manual Setup
294
+
295
+ If you're migrating from manually copied composables:
296
+
297
+ ```typescript
298
+ // Before:
299
+ import { useTextContent } from '@/lib/use-text-content'
300
+
301
+ // After:
302
+ import { useTextContent } from '@duffcloudservices/cms'
303
+ ```
304
+
305
+ The API is the same, so no other code changes are needed.
306
+
307
+ ## License
308
+
309
+ MIT