@xleddyl/nuxt-cms 0.10.0 → 0.11.0

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
3
  "configKey": "cms",
4
- "version": "0.10.0",
4
+ "version": "0.11.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -2302,6 +2302,12 @@ ${webhooks.errors.join("\n")}`);
2302
2302
  { name: "useCmsContents", from: entryStub },
2303
2303
  { name: "useCmsContent", from: entryStub },
2304
2304
  { name: "useCmsRoute", from: entryStub },
2305
+ { name: "$cmsSingle", from: entryStub },
2306
+ { name: "$cmsCollection", from: entryStub },
2307
+ { name: "$cmsPage", from: entryStub },
2308
+ { name: "$cmsContents", from: entryStub },
2309
+ { name: "$cmsContent", from: entryStub },
2310
+ { name: "$cmsRoute", from: entryStub },
2305
2311
  {
2306
2312
  name: "useCmsSite",
2307
2313
  from: resolver.resolve("./runtime/app/composables/cms-site-disabled")
@@ -2415,6 +2421,12 @@ ${webhooks.errors.join("\n")}`);
2415
2421
  { name: "useCmsContents", from: entryComposables },
2416
2422
  { name: "useCmsContent", from: entryComposables },
2417
2423
  { name: "useCmsRoute", from: entryComposables },
2424
+ { name: "$cmsSingle", from: entryComposables },
2425
+ { name: "$cmsCollection", from: entryComposables },
2426
+ { name: "$cmsPage", from: entryComposables },
2427
+ { name: "$cmsContents", from: entryComposables },
2428
+ { name: "$cmsContent", from: entryComposables },
2429
+ { name: "$cmsRoute", from: entryComposables },
2418
2430
  {
2419
2431
  name: "useCmsPreviewMode",
2420
2432
  from: resolver.resolve("./runtime/app/composables/cms-preview-mode")
@@ -221,8 +221,7 @@
221
221
  <KFormField
222
222
  :name="editorFieldName(blockKey)"
223
223
  :label="editorBlock.fields[blockKey].label"
224
- :description="editorBlock.fields[blockKey].description"
225
- :icon="cmsIcon(fieldIcon(editorBlock.fields[blockKey]))"
224
+ :help="editorBlock.fields[blockKey].description"
226
225
  :required="editorBlock.fields[blockKey].required"
227
226
  >
228
227
  <CmsFieldInput
@@ -357,7 +356,7 @@ import { useCmsRuntime } from "../../composables/cms-runtime";
357
356
  import { useCmsOverlayFlag } from "../../composables/cms-route";
358
357
  import { CMS_BLOCK_EDITOR, CmsBlockEditorProvider } from "../../utils/block-editor";
359
358
  import { clipboardTarget } from "../../utils/keyboard";
360
- import { cmsIcon, fieldIcon } from "../../utils/ui";
359
+ import { cmsIcon } from "../../utils/ui";
361
360
  const props = defineProps({
362
361
  field: { type: Object, required: true },
363
362
  locale: { type: String, required: false },
@@ -13,8 +13,7 @@
13
13
  <KFormField
14
14
  :name="key"
15
15
  :label="fields[key].label"
16
- :description="fields[key].description"
17
- :icon="cmsIcon(fieldIcon(fields[key]))"
16
+ :help="fields[key].description"
18
17
  :required="fields[key].required"
19
18
  :disabled="locked.includes(key) || void 0"
20
19
  :highlight="highlighted === key"
@@ -68,7 +67,7 @@ import { useCmsEntryForm } from "../../composables/cms-entry-form";
68
67
  import { useCmsPageQuery } from "../../composables/cms-route";
69
68
  import { useCmsRuntime } from "../../composables/cms-runtime";
70
69
  import { entryFormLayout, useCmsSettingsState } from "../../composables/cms-settings";
71
- import { cmsIcon, fieldIcon } from "../../utils/ui";
70
+ import { cmsIcon } from "../../utils/ui";
72
71
  const props = defineProps({
73
72
  fields: { type: Object, required: true },
74
73
  tabs: { type: Array, required: false },
@@ -20,11 +20,6 @@ const props = defineProps({
20
20
  });
21
21
  const model = defineModel({ type: String, ...{ required: true } });
22
22
  const { i18n } = useCmsRuntime();
23
- function stateOf(locale) {
24
- const progress = props.progress?.[locale];
25
- if (locale === i18n.defaultLocale || !progress?.total) return null;
26
- return progress.state;
27
- }
28
23
  function titleOf(locale) {
29
24
  const progress = props.progress?.[locale];
30
25
  if (!progress) return void 0;
@@ -34,23 +29,12 @@ function titleOf(locale) {
34
29
  if (!progress.total) return progress.values ? void 0 : `${locale}: empty`;
35
30
  return `${locale}: ${translationSummary(progress)}`;
36
31
  }
37
- const DOT_TONES = {
38
- complete: "success",
39
- partial: "warning",
40
- missing: "danger"
41
- };
42
32
  const options = computed(
43
- () => i18n.locales.map((locale) => {
44
- const state = stateOf(locale);
45
- return {
46
- value: locale,
47
- label: locale,
48
- title: titleOf(locale),
49
- muted: !!props.progress && !props.progress[locale]?.values,
50
- dot: !!state,
51
- dotTone: state ? DOT_TONES[state] : void 0,
52
- dotLabel: state ? titleOf(locale) : void 0
53
- };
54
- })
33
+ () => i18n.locales.map((locale) => ({
34
+ value: locale,
35
+ label: locale,
36
+ title: titleOf(locale),
37
+ muted: !!props.progress && !props.progress[locale]?.values
38
+ }))
55
39
  );
56
40
  </script>
@@ -3,9 +3,7 @@
3
3
  <KBadge
4
4
  :label="ENTRY_SETTINGS_STATUS_LABELS[status]"
5
5
  :tone="STATUS_TONES[status]"
6
- :pulse="status === 'saving'"
7
6
  variant="outline"
8
- dot
9
7
  aria-live="polite"
10
8
  />
11
9
  <KButton
@@ -22,7 +22,7 @@
22
22
  <KFormField
23
23
  label="Title template"
24
24
  name="titleTemplate"
25
- :description="`${TITLE_PLACEHOLDER} is the page title, ${SITE_NAME_PLACEHOLDER} the site name.`"
25
+ :help="`${TITLE_PLACEHOLDER} is the page title, ${SITE_NAME_PLACEHOLDER} the site name.`"
26
26
  >
27
27
  <KInput v-model="titleTemplate" :placeholder="DEFAULT_TITLE_TEMPLATE" />
28
28
  </KFormField>
@@ -4,7 +4,6 @@
4
4
  :label="scheduled ? 'Scheduled' : published ? 'Published' : 'Draft'"
5
5
  :tone="scheduled ? 'warning' : published ? 'success' : 'neutral'"
6
6
  :variant="scheduled || published ? 'soft' : 'outline'"
7
- dot
8
7
  />
9
8
  </KTooltip>
10
9
  </template>
@@ -6,7 +6,6 @@
6
6
  :tone="badge.tone"
7
7
  :variant="badge.variant"
8
8
  size="sm"
9
- dot
10
9
  class="cms-code"
11
10
  :aria-label="badge.title"
12
11
  />
@@ -229,8 +229,7 @@
229
229
  <KFormField
230
230
  :name="`${selectedName}.${blockKey}`"
231
231
  :label="selectedBlock.fields[blockKey].label"
232
- :description="selectedBlock.fields[blockKey].description"
233
- :icon="cmsIcon(fieldIcon(selectedBlock.fields[blockKey]))"
232
+ :help="selectedBlock.fields[blockKey].description"
234
233
  :required="selectedBlock.fields[blockKey].required"
235
234
  :highlight="highlighted === blockKey"
236
235
  >
@@ -278,8 +277,7 @@
278
277
  <KFormField
279
278
  :name="key"
280
279
  :label="fields[key].label"
281
- :description="fields[key].description"
282
- :icon="cmsIcon(fieldIcon(fields[key]))"
280
+ :help="fields[key].description"
283
281
  :required="fields[key].required"
284
282
  :disabled="locked?.includes(key) || void 0"
285
283
  :highlight="highlighted === key"
@@ -442,7 +440,7 @@ import {
442
440
  onApplePlatform,
443
441
  shortcutTarget
444
442
  } from "../../utils/keyboard";
445
- import { cmsIcon, fieldIcon } from "../../utils/ui";
443
+ import { cmsIcon } from "../../utils/ui";
446
444
  const SEO_KEYS = ["seoTitle", "seoDescription", "seoImage", "seoNoindex"];
447
445
  const deviceOptions = [
448
446
  { value: "desktop", label: "Desktop width", icon: cmsIcon("computer-desktop") },
@@ -5,26 +5,32 @@ export interface CmsSortInput<Entry> {
5
5
  field: Extract<keyof Entry, string>;
6
6
  direction?: 'asc' | 'desc';
7
7
  }
8
- export interface CmsSingleOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
8
+ export interface CmsEntryQuery {
9
9
  locale?: string;
10
10
  }
11
- export interface CmsPageOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
12
- locale?: string;
13
- }
14
- export interface CmsCollectionOptions<ResT, DefaultT, Entry> extends CmsAsyncDataOptions<ResT, DefaultT> {
15
- locale?: string;
11
+ export interface CmsListQuery<Entry> extends CmsEntryQuery {
16
12
  filters?: Record<string, unknown>;
17
13
  sort?: CmsSortInput<Entry>[];
18
14
  limit?: number;
19
15
  offset?: number;
20
16
  }
21
- export interface CmsContentOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
22
- locale?: string;
17
+ export interface CmsSingleOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
18
+ }
19
+ export interface CmsPageOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
20
+ }
21
+ export interface CmsCollectionOptions<ResT, DefaultT, Entry> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsListQuery<Entry> {
22
+ }
23
+ export interface CmsContentOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
23
24
  }
24
25
  export type CmsContentsOptions<ResT, DefaultT, Entry> = CmsCollectionOptions<ResT, DefaultT, Entry>;
25
- export interface CmsRouteOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
26
- locale?: string;
26
+ export interface CmsRouteOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
27
27
  }
28
+ export declare function $cmsSingle<K extends CmsSingleName>(name: K, query?: CmsEntryQuery): Promise<CmsSingleTypes[K] | null>;
29
+ export declare function $cmsCollection<K extends CmsCollectionName>(name: K, query?: CmsListQuery<CmsCollectionTypes[K]>): Promise<CmsCollectionTypes[K][]>;
30
+ export declare function $cmsContents<K extends CmsContentName>(name: K, query?: CmsListQuery<CmsContentTypes[K]>): Promise<CmsContentTypes[K][]>;
31
+ export declare function $cmsContent<K extends CmsContentName>(name: K, slug: string, query?: CmsEntryQuery): Promise<CmsContentTypes[K] | null>;
32
+ export declare function $cmsPage<P extends CmsPagePath>(path: P, query?: CmsEntryQuery): Promise<CmsPageTypes[P] | null>;
33
+ export declare function $cmsRoute(path: string, query?: CmsEntryQuery): Promise<CmsContentRouteMatch | null>;
28
34
  export declare function useCmsSingle<K extends CmsSingleName, DefaultT = null>(name: K, options?: CmsSingleOptions<CmsSingleTypes[K] | null, DefaultT>): AsyncData<CmsSingleTypes[K] | DefaultT | null, Error | undefined>;
29
35
  export declare function useCmsCollection<K extends CmsCollectionName, DefaultT = CmsCollectionTypes[K][]>(name: K, options?: CmsCollectionOptions<CmsCollectionTypes[K][], DefaultT, CmsCollectionTypes[K]>): AsyncData<CmsCollectionTypes[K][] | DefaultT, Error | undefined>;
30
36
  export declare function useCmsContents<K extends CmsContentName, DefaultT = CmsContentTypes[K][]>(name: K, options?: CmsContentsOptions<CmsContentTypes[K][], DefaultT, CmsContentTypes[K]>): AsyncData<CmsContentTypes[K][] | DefaultT, Error | undefined>;
@@ -1,4 +1,22 @@
1
1
  import { useAsyncData } from "#imports";
2
+ export async function $cmsSingle(name, query = {}) {
3
+ return null;
4
+ }
5
+ export async function $cmsCollection(name, query = {}) {
6
+ return [];
7
+ }
8
+ export async function $cmsContents(name, query = {}) {
9
+ return [];
10
+ }
11
+ export async function $cmsContent(name, slug, query = {}) {
12
+ return null;
13
+ }
14
+ export async function $cmsPage(path, query = {}) {
15
+ return null;
16
+ }
17
+ export async function $cmsRoute(path, query = {}) {
18
+ return null;
19
+ }
2
20
  export function useCmsSingle(name, options = {}) {
3
21
  const { locale, key, default: fallback } = options;
4
22
  return useAsyncData(
@@ -5,26 +5,32 @@ export interface CmsSortInput<Entry> {
5
5
  field: Extract<keyof Entry, string>;
6
6
  direction?: 'asc' | 'desc';
7
7
  }
8
- export interface CmsSingleOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
8
+ export interface CmsEntryQuery {
9
9
  locale?: string;
10
10
  }
11
- export interface CmsPageOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
12
- locale?: string;
13
- }
14
- export interface CmsCollectionOptions<ResT, DefaultT, Entry> extends CmsAsyncDataOptions<ResT, DefaultT> {
15
- locale?: string;
11
+ export interface CmsListQuery<Entry> extends CmsEntryQuery {
16
12
  filters?: Record<string, unknown>;
17
13
  sort?: CmsSortInput<Entry>[];
18
14
  limit?: number;
19
15
  offset?: number;
20
16
  }
21
- export interface CmsContentOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
22
- locale?: string;
17
+ export interface CmsSingleOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
18
+ }
19
+ export interface CmsPageOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
20
+ }
21
+ export interface CmsCollectionOptions<ResT, DefaultT, Entry> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsListQuery<Entry> {
22
+ }
23
+ export interface CmsContentOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
23
24
  }
24
25
  export type CmsContentsOptions<ResT, DefaultT, Entry> = CmsCollectionOptions<ResT, DefaultT, Entry>;
25
- export interface CmsRouteOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT> {
26
- locale?: string;
26
+ export interface CmsRouteOptions<ResT, DefaultT> extends CmsAsyncDataOptions<ResT, DefaultT>, CmsEntryQuery {
27
27
  }
28
+ export declare function $cmsSingle<K extends CmsSingleName>(name: K, query?: CmsEntryQuery): Promise<CmsSingleTypes[K] | null>;
29
+ export declare function $cmsCollection<K extends CmsCollectionName>(name: K, query?: CmsListQuery<CmsCollectionTypes[K]>): Promise<CmsCollectionTypes[K][]>;
30
+ export declare function $cmsContents<K extends CmsContentName>(name: K, query?: CmsListQuery<CmsContentTypes[K]>): Promise<CmsContentTypes[K][]>;
31
+ export declare function $cmsContent<K extends CmsContentName>(name: K, slug: string, query?: CmsEntryQuery): Promise<CmsContentTypes[K] | null>;
32
+ export declare function $cmsPage<P extends CmsPagePath>(path: P, query?: CmsEntryQuery): Promise<CmsPageTypes[P] | null>;
33
+ export declare function $cmsRoute(path: string, query?: CmsEntryQuery): Promise<null>;
28
34
  export declare function useCmsSingle<K extends CmsSingleName, DefaultT = null>(name: K, options?: CmsSingleOptions<CmsSingleTypes[K] | null, DefaultT>): AsyncData<CmsSingleTypes[K] | DefaultT | null, Error | undefined>;
29
35
  export declare function useCmsCollection<K extends CmsCollectionName, DefaultT = CmsCollectionTypes[K][]>(name: K, options?: CmsCollectionOptions<CmsCollectionTypes[K][], DefaultT, CmsCollectionTypes[K]>): AsyncData<CmsCollectionTypes[K][] | DefaultT, Error | undefined>;
30
36
  export declare function useCmsContents<K extends CmsContentName, DefaultT = CmsContentTypes[K][]>(name: K, options?: CmsContentsOptions<CmsContentTypes[K][], DefaultT, CmsContentTypes[K]>): AsyncData<CmsContentTypes[K][] | DefaultT, Error | undefined>;
@@ -12,18 +12,75 @@ import { cmsPreviewKey, cmsPreviewToken, cmsQueryWithPreview } from "./cms-query
12
12
  function unknownEntry(name) {
13
13
  throw new Error(`[nuxt-cms] no generated query for "${name}"; check cms.config.ts`);
14
14
  }
15
- export function useCmsSingle(name, options = {}) {
16
- const { locale, key, default: fallback, ...asyncDataOptions } = options;
15
+ function listVariables({ locale, filters, sort, limit, offset }) {
16
+ return { locale, filters, sort, limit, offset };
17
+ }
18
+ async function fetchSingle(name, { locale }, preview) {
17
19
  const entryName = String(name);
18
20
  const query = cmsSingleQueries[entryName];
21
+ if (!query) unknownEntry(entryName);
22
+ const result = await cmsQueryWithPreview(query, { locale }, preview);
23
+ return result?.[entryName] ?? null;
24
+ }
25
+ async function fetchCollection(name, listQuery, preview) {
26
+ const entryName = String(name);
27
+ const query = cmsCollectionQueries[entryName];
28
+ if (!query) unknownEntry(entryName);
29
+ const result = await cmsQueryWithPreview(query, listVariables(listQuery), preview);
30
+ return result?.[entryName] ?? [];
31
+ }
32
+ async function fetchContents(name, listQuery, preview) {
33
+ const entryName = String(name);
34
+ const query = cmsContentQueries[entryName];
35
+ if (!query) unknownEntry(entryName);
36
+ const result = await cmsQueryWithPreview(query, listVariables(listQuery), preview);
37
+ return result?.[entryName] ?? [];
38
+ }
39
+ async function fetchContent(name, slug, { locale }, preview) {
40
+ const entryName = String(name);
41
+ const query = cmsContentItemQueries[entryName];
42
+ if (!query) unknownEntry(entryName);
43
+ const result = await cmsQueryWithPreview(query, { slug, locale }, preview);
44
+ return result?.item ?? null;
45
+ }
46
+ async function fetchPage(path, { locale }, preview) {
47
+ const pagePath = String(path);
48
+ const query = cmsPageQueries[pagePath];
49
+ if (!query) unknownEntry(pagePath);
50
+ const result = await cmsQueryWithPreview(query, { path: pagePath, locale }, preview);
51
+ return result?.page ?? null;
52
+ }
53
+ async function fetchRoute(path, { locale }, preview) {
54
+ if (!cmsRouteQuery) return null;
55
+ const result = await cmsQueryWithPreview(cmsRouteQuery, { path, locale }, preview);
56
+ const entry = cmsRouteEntries.find((name) => result?.[name]);
57
+ if (!entry) return null;
58
+ return { entry, item: result[entry] };
59
+ }
60
+ export function $cmsSingle(name, query = {}) {
61
+ return fetchSingle(name, query, cmsPreviewToken());
62
+ }
63
+ export function $cmsCollection(name, query = {}) {
64
+ return fetchCollection(name, query, cmsPreviewToken());
65
+ }
66
+ export function $cmsContents(name, query = {}) {
67
+ return fetchContents(name, query, cmsPreviewToken());
68
+ }
69
+ export function $cmsContent(name, slug, query = {}) {
70
+ return fetchContent(name, slug, query, cmsPreviewToken());
71
+ }
72
+ export function $cmsPage(path, query = {}) {
73
+ return fetchPage(path, query, cmsPreviewToken());
74
+ }
75
+ export function $cmsRoute(path, query = {}) {
76
+ return fetchRoute(path, query, cmsPreviewToken());
77
+ }
78
+ export function useCmsSingle(name, options = {}) {
79
+ const { locale, key, default: fallback, ...asyncDataOptions } = options;
19
80
  const preview = cmsPreviewToken();
20
81
  return useAsyncData(
21
- key ?? cmsPreviewKey(`cms-single:${entryName}:${locale ?? ""}`, preview),
22
- async () => {
23
- if (!query) unknownEntry(entryName);
24
- const result = await cmsQueryWithPreview(query, { locale }, preview);
25
- return result?.[entryName] ?? null;
26
- },
82
+ key ?? cmsPreviewKey(`cms-single:${String(name)}:${locale ?? ""}`, preview),
83
+ () => fetchSingle(name, { locale }, preview),
27
84
  {
28
85
  default: fallback ?? (() => null),
29
86
  ...asyncDataOptions
@@ -41,17 +98,11 @@ export function useCmsCollection(name, options = {}) {
41
98
  default: fallback,
42
99
  ...asyncDataOptions
43
100
  } = options;
44
- const entryName = String(name);
45
- const query = cmsCollectionQueries[entryName];
46
101
  const variables = { locale, filters, sort, limit, offset };
47
102
  const preview = cmsPreviewToken();
48
103
  return useAsyncData(
49
- key ?? cmsPreviewKey(`cms-collection:${entryName}:${JSON.stringify(variables)}`, preview),
50
- async () => {
51
- if (!query) unknownEntry(entryName);
52
- const result = await cmsQueryWithPreview(query, variables, preview);
53
- return result?.[entryName] ?? [];
54
- },
104
+ key ?? cmsPreviewKey(`cms-collection:${String(name)}:${JSON.stringify(variables)}`, preview),
105
+ () => fetchCollection(name, variables, preview),
55
106
  {
56
107
  default: fallback ?? (() => []),
57
108
  ...asyncDataOptions
@@ -69,17 +120,11 @@ export function useCmsContents(name, options = {}) {
69
120
  default: fallback,
70
121
  ...asyncDataOptions
71
122
  } = options;
72
- const entryName = String(name);
73
- const query = cmsContentQueries[entryName];
74
123
  const variables = { locale, filters, sort, limit, offset };
75
124
  const preview = cmsPreviewToken();
76
125
  return useAsyncData(
77
- key ?? cmsPreviewKey(`cms-contents:${entryName}:${JSON.stringify(variables)}`, preview),
78
- async () => {
79
- if (!query) unknownEntry(entryName);
80
- const result = await cmsQueryWithPreview(query, variables, preview);
81
- return result?.[entryName] ?? [];
82
- },
126
+ key ?? cmsPreviewKey(`cms-contents:${String(name)}:${JSON.stringify(variables)}`, preview),
127
+ () => fetchContents(name, variables, preview),
83
128
  {
84
129
  default: fallback ?? (() => []),
85
130
  ...asyncDataOptions
@@ -88,16 +133,10 @@ export function useCmsContents(name, options = {}) {
88
133
  }
89
134
  export function useCmsContent(name, slug, options = {}) {
90
135
  const { locale, key, default: fallback, ...asyncDataOptions } = options;
91
- const entryName = String(name);
92
- const query = cmsContentItemQueries[entryName];
93
136
  const preview = cmsPreviewToken();
94
137
  return useAsyncData(
95
- key ?? cmsPreviewKey(`cms-content:${entryName}:${slug}:${locale ?? ""}`, preview),
96
- async () => {
97
- if (!query) unknownEntry(entryName);
98
- const result = await cmsQueryWithPreview(query, { slug, locale }, preview);
99
- return result?.item ?? null;
100
- },
138
+ key ?? cmsPreviewKey(`cms-content:${String(name)}:${slug}:${locale ?? ""}`, preview),
139
+ () => fetchContent(name, slug, { locale }, preview),
101
140
  {
102
141
  default: fallback ?? (() => null),
103
142
  ...asyncDataOptions
@@ -106,16 +145,10 @@ export function useCmsContent(name, slug, options = {}) {
106
145
  }
107
146
  export function useCmsPage(path, options = {}) {
108
147
  const { locale, key, default: fallback, ...asyncDataOptions } = options;
109
- const pagePath = String(path);
110
- const query = cmsPageQueries[pagePath];
111
148
  const preview = cmsPreviewToken();
112
149
  return useAsyncData(
113
- key ?? cmsPreviewKey(`cms-page:${pagePath}:${locale ?? ""}`, preview),
114
- async () => {
115
- if (!query) unknownEntry(pagePath);
116
- const result = await cmsQueryWithPreview(query, { path: pagePath, locale }, preview);
117
- return result?.page ?? null;
118
- },
150
+ key ?? cmsPreviewKey(`cms-page:${String(path)}:${locale ?? ""}`, preview),
151
+ () => fetchPage(path, { locale }, preview),
119
152
  {
120
153
  default: fallback ?? (() => null),
121
154
  ...asyncDataOptions
@@ -127,13 +160,7 @@ export function useCmsRoute(path, options = {}) {
127
160
  const preview = cmsPreviewToken();
128
161
  return useAsyncData(
129
162
  key ?? cmsPreviewKey(`cms-route:${path}:${locale ?? ""}`, preview),
130
- async () => {
131
- if (!cmsRouteQuery) return null;
132
- const result = await cmsQueryWithPreview(cmsRouteQuery, { path, locale }, preview);
133
- const entry = cmsRouteEntries.find((name) => result?.[name]);
134
- if (!entry) return null;
135
- return { entry, item: result[entry] };
136
- },
163
+ () => fetchRoute(path, { locale }, preview),
137
164
  {
138
165
  default: fallback ?? (() => null),
139
166
  ...asyncDataOptions
@@ -27,7 +27,7 @@
27
27
 
28
28
  <template #status>
29
29
  <CmsStatusBadge :published="published" :scheduled="scheduled" :at="scheduledAt" />
30
- <KBadge v-if="dirty" label="Unsaved changes" tone="warning" dot />
30
+ <KBadge v-if="dirty" label="Unsaved changes" tone="warning" />
31
31
  <KTooltip v-if="lock" :text="lock">
32
32
  <KBadge size="sm" variant="outline" label="Read only" />
33
33
  </KTooltip>
@@ -84,7 +84,7 @@
84
84
  <KStack gap="md">
85
85
  <KFormField
86
86
  label="Publish at"
87
- description="The item stays hidden from the site until this moment."
87
+ help="The item stays hidden from the site until this moment."
88
88
  >
89
89
  <CmsFieldInput v-model="scheduleDraft" :field="publishedAtField" />
90
90
  </KFormField>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",