qarpeo 0.1.7 → 0.1.8
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/LICENSE +21 -21
- package/README.md +102 -102
- package/dist/module.mjs +1 -1
- package/dist/runtime/app/components/BlobImage.vue +100 -100
- package/dist/runtime/app/components/CMSBlocks.vue +93 -93
- package/dist/runtime/app/components/CMSContent.vue +23 -23
- package/dist/runtime/app/components/CMSImage.vue +49 -49
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
- package/dist/runtime/app/components/CMSPreviewBanner.vue +79 -79
- package/dist/runtime/app/components/CMSVersionBanner.vue +49 -49
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
- package/dist/runtime/app/components/ContentRenderer.vue +80 -80
- package/dist/runtime/app/components/FileUpload.vue +196 -196
- package/dist/runtime/app/components/ImpersonationBanner.vue +57 -57
- package/dist/runtime/app/components/SignedIn.vue +13 -13
- package/dist/runtime/app/components/SignedOut.vue +13 -13
- package/dist/runtime/app/components/shiki.css +34 -34
- package/dist/runtime/app/pages/cms.vue +2249 -2249
- package/dist/runtime/app/pages/devtools/overview.vue +390 -390
- package/dist/runtime/app/pages/devtools/settings.vue +560 -560
- package/dist/runtime/app/pages/devtools.vue +165 -165
- package/dist/runtime/app/public/sw-notifications.mjs +52 -52
- package/dist/runtime/server/utils/cms.mjs +92 -13
- package/dist/runtime/types/auth-globals.d.ts +14 -14
- package/dist/runtime/types/imports.d.ts +58 -58
- package/package.json +3 -3
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
/**
|
|
3
|
-
* `<CMSContent>` — Renders raw HTML CMS content safely via innerHTML.
|
|
4
|
-
*/
|
|
5
|
-
withDefaults(defineProps<{
|
|
6
|
-
content?: string
|
|
7
|
-
value?: Record<string, any> | null
|
|
8
|
-
as?: string
|
|
9
|
-
}>(), {
|
|
10
|
-
content: "",
|
|
11
|
-
value: null,
|
|
12
|
-
as: "div",
|
|
13
|
-
})
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<template>
|
|
17
|
-
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
18
|
-
<component
|
|
19
|
-
:is="as"
|
|
20
|
-
class="qarpeo-cms-content"
|
|
21
|
-
v-html="content || (value as any)?.contentHtml || ''"
|
|
22
|
-
/>
|
|
23
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
/**
|
|
3
|
+
* `<CMSContent>` — Renders raw HTML CMS content safely via innerHTML.
|
|
4
|
+
*/
|
|
5
|
+
withDefaults(defineProps<{
|
|
6
|
+
content?: string
|
|
7
|
+
value?: Record<string, any> | null
|
|
8
|
+
as?: string
|
|
9
|
+
}>(), {
|
|
10
|
+
content: "",
|
|
11
|
+
value: null,
|
|
12
|
+
as: "div",
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
18
|
+
<component
|
|
19
|
+
:is="as"
|
|
20
|
+
class="qarpeo-cms-content"
|
|
21
|
+
v-html="content || (value as any)?.contentHtml || ''"
|
|
22
|
+
/>
|
|
23
|
+
</template>
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed } from "vue"
|
|
3
|
-
import { useStorage } from "../composables/storage"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `<CMSImage>` — Renders an optimized CMS-managed image via Qarpeo blob storage.
|
|
7
|
-
* Similar to `<BlobImage>` but focused on CMS content images.
|
|
8
|
-
*/
|
|
9
|
-
const props = withDefaults(defineProps<{
|
|
10
|
-
src?: string
|
|
11
|
-
preset?: string
|
|
12
|
-
width?: number | string
|
|
13
|
-
height?: number | string
|
|
14
|
-
quality?: number | string
|
|
15
|
-
format?: string
|
|
16
|
-
fit?: string
|
|
17
|
-
alt?: string
|
|
18
|
-
loading?: "lazy" | "eager"
|
|
19
|
-
}>(), {
|
|
20
|
-
src: "",
|
|
21
|
-
alt: "",
|
|
22
|
-
loading: "lazy",
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const { getOptimizedImageUrl } = useStorage()
|
|
26
|
-
|
|
27
|
-
const resolvedUrl = computed(() => {
|
|
28
|
-
if (!props.src) return ""
|
|
29
|
-
if ((props.src.startsWith("http://") || props.src.startsWith("https://")) && !props.preset) {
|
|
30
|
-
return props.src
|
|
31
|
-
}
|
|
32
|
-
return getOptimizedImageUrl(props.src, {
|
|
33
|
-
preset: props.preset,
|
|
34
|
-
width: props.width ? Number(props.width) : undefined,
|
|
35
|
-
height: props.height ? Number(props.height) : undefined,
|
|
36
|
-
quality: props.quality ? Number(props.quality) : undefined,
|
|
37
|
-
format: props.format as any,
|
|
38
|
-
fit: props.fit as any,
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<template>
|
|
44
|
-
<img
|
|
45
|
-
:src="resolvedUrl"
|
|
46
|
-
:alt="alt"
|
|
47
|
-
:loading="loading"
|
|
48
|
-
/>
|
|
49
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
import { useStorage } from "../composables/storage"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `<CMSImage>` — Renders an optimized CMS-managed image via Qarpeo blob storage.
|
|
7
|
+
* Similar to `<BlobImage>` but focused on CMS content images.
|
|
8
|
+
*/
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
src?: string
|
|
11
|
+
preset?: string
|
|
12
|
+
width?: number | string
|
|
13
|
+
height?: number | string
|
|
14
|
+
quality?: number | string
|
|
15
|
+
format?: string
|
|
16
|
+
fit?: string
|
|
17
|
+
alt?: string
|
|
18
|
+
loading?: "lazy" | "eager"
|
|
19
|
+
}>(), {
|
|
20
|
+
src: "",
|
|
21
|
+
alt: "",
|
|
22
|
+
loading: "lazy",
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const { getOptimizedImageUrl } = useStorage()
|
|
26
|
+
|
|
27
|
+
const resolvedUrl = computed(() => {
|
|
28
|
+
if (!props.src) return ""
|
|
29
|
+
if ((props.src.startsWith("http://") || props.src.startsWith("https://")) && !props.preset) {
|
|
30
|
+
return props.src
|
|
31
|
+
}
|
|
32
|
+
return getOptimizedImageUrl(props.src, {
|
|
33
|
+
preset: props.preset,
|
|
34
|
+
width: props.width ? Number(props.width) : undefined,
|
|
35
|
+
height: props.height ? Number(props.height) : undefined,
|
|
36
|
+
quality: props.quality ? Number(props.quality) : undefined,
|
|
37
|
+
format: props.format as any,
|
|
38
|
+
fit: props.fit as any,
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<img
|
|
45
|
+
:src="resolvedUrl"
|
|
46
|
+
:alt="alt"
|
|
47
|
+
:loading="loading"
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed } from "vue"
|
|
3
|
-
import { useCMSLocale } from "../composables/cms"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `<CMSLocaleSwitcher>` — Nuxt UI selector for switching between configured CMS content locales.
|
|
7
|
-
* Updates `useCMSLocale()` state, persists preference in cookie, and updates page content.
|
|
8
|
-
*/
|
|
9
|
-
const props = withDefaults(
|
|
10
|
-
defineProps<{
|
|
11
|
-
variant?: "dropdown" | "select" | "buttons"
|
|
12
|
-
size?: "xs" | "sm" | "md"
|
|
13
|
-
color?: "neutral" | "primary"
|
|
14
|
-
showFlags?: boolean
|
|
15
|
-
class?: string
|
|
16
|
-
}>(),
|
|
17
|
-
{
|
|
18
|
-
variant: "dropdown",
|
|
19
|
-
size: "xs",
|
|
20
|
-
color: "neutral",
|
|
21
|
-
showFlags: true,
|
|
22
|
-
class: "",
|
|
23
|
-
},
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
const { locale, localeConfigs, setLocale } = useCMSLocale()
|
|
27
|
-
|
|
28
|
-
const activeConfig = computed(
|
|
29
|
-
() => localeConfigs.value?.find((c) => c.code === locale.value) || localeConfigs.value?.[0],
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const dropdownItems = computed(() => [
|
|
33
|
-
(localeConfigs.value || []).map((c) => ({
|
|
34
|
-
label: `${props.showFlags && c.flag ? `${c.flag} ` : ""}${c.name}`,
|
|
35
|
-
icon: c.code === locale.value ? "i-lucide-check" : undefined,
|
|
36
|
-
onSelect: () => setLocale(c.code),
|
|
37
|
-
})),
|
|
38
|
-
])
|
|
39
|
-
|
|
40
|
-
const selectItems = computed(() =>
|
|
41
|
-
(localeConfigs.value || []).map((c) => ({
|
|
42
|
-
label: `${props.showFlags && c.flag ? `${c.flag} ` : ""}${c.name}`,
|
|
43
|
-
value: c.code,
|
|
44
|
-
})),
|
|
45
|
-
)
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<template>
|
|
49
|
-
<template v-if="localeConfigs && localeConfigs.length > 1">
|
|
50
|
-
<!-- Buttons variant -->
|
|
51
|
-
<div
|
|
52
|
-
v-if="variant === 'buttons'"
|
|
53
|
-
:class="['inline-flex items-center gap-1 rounded-lg border border-gray-200 dark:border-gray-800 p-1 bg-gray-50/50 dark:bg-gray-900/50 text-xs font-medium', props.class]"
|
|
54
|
-
role="group"
|
|
55
|
-
aria-label="Language switcher"
|
|
56
|
-
>
|
|
57
|
-
<UButton
|
|
58
|
-
v-for="c in localeConfigs"
|
|
59
|
-
:key="c.code"
|
|
60
|
-
:size="size"
|
|
61
|
-
:variant="c.code === locale ? 'solid' : 'ghost'"
|
|
62
|
-
:color="color"
|
|
63
|
-
:label="c.name"
|
|
64
|
-
:class="[
|
|
65
|
-
'flex items-center gap-1.5',
|
|
66
|
-
c.code === locale
|
|
67
|
-
? 'bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-xs font-semibold'
|
|
68
|
-
: 'text-gray-600 dark:text-gray-400',
|
|
69
|
-
]"
|
|
70
|
-
@click="setLocale(c.code)"
|
|
71
|
-
>
|
|
72
|
-
<template v-if="showFlags && c.flag" #leading>
|
|
73
|
-
<span class="text-sm leading-none">{{ c.flag }}</span>
|
|
74
|
-
</template>
|
|
75
|
-
</UButton>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<!-- Select variant: Nuxt UI USelect -->
|
|
79
|
-
<USelect
|
|
80
|
-
v-else-if="variant === 'select'"
|
|
81
|
-
:model-value="locale"
|
|
82
|
-
:items="selectItems"
|
|
83
|
-
:size="size"
|
|
84
|
-
:color="color"
|
|
85
|
-
variant="subtle"
|
|
86
|
-
:class="props.class"
|
|
87
|
-
@update:model-value="setLocale($event)"
|
|
88
|
-
/>
|
|
89
|
-
|
|
90
|
-
<!-- Dropdown variant (DEFAULT): Nuxt UI UDropdownMenu -->
|
|
91
|
-
<UDropdownMenu
|
|
92
|
-
v-else
|
|
93
|
-
:items="dropdownItems"
|
|
94
|
-
:content="{ align: 'start' }"
|
|
95
|
-
>
|
|
96
|
-
<UButton
|
|
97
|
-
:size="size"
|
|
98
|
-
variant="outline"
|
|
99
|
-
:color="color"
|
|
100
|
-
:label="activeConfig?.name"
|
|
101
|
-
trailing-icon="i-lucide-chevron-down"
|
|
102
|
-
:class="props.class"
|
|
103
|
-
>
|
|
104
|
-
<template v-if="showFlags && activeConfig?.flag" #leading>
|
|
105
|
-
<span class="text-sm leading-none">{{ activeConfig.flag }}</span>
|
|
106
|
-
</template>
|
|
107
|
-
</UButton>
|
|
108
|
-
</UDropdownMenu>
|
|
109
|
-
</template>
|
|
110
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
import { useCMSLocale } from "../composables/cms"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `<CMSLocaleSwitcher>` — Nuxt UI selector for switching between configured CMS content locales.
|
|
7
|
+
* Updates `useCMSLocale()` state, persists preference in cookie, and updates page content.
|
|
8
|
+
*/
|
|
9
|
+
const props = withDefaults(
|
|
10
|
+
defineProps<{
|
|
11
|
+
variant?: "dropdown" | "select" | "buttons"
|
|
12
|
+
size?: "xs" | "sm" | "md"
|
|
13
|
+
color?: "neutral" | "primary"
|
|
14
|
+
showFlags?: boolean
|
|
15
|
+
class?: string
|
|
16
|
+
}>(),
|
|
17
|
+
{
|
|
18
|
+
variant: "dropdown",
|
|
19
|
+
size: "xs",
|
|
20
|
+
color: "neutral",
|
|
21
|
+
showFlags: true,
|
|
22
|
+
class: "",
|
|
23
|
+
},
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const { locale, localeConfigs, setLocale } = useCMSLocale()
|
|
27
|
+
|
|
28
|
+
const activeConfig = computed(
|
|
29
|
+
() => localeConfigs.value?.find((c) => c.code === locale.value) || localeConfigs.value?.[0],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const dropdownItems = computed(() => [
|
|
33
|
+
(localeConfigs.value || []).map((c) => ({
|
|
34
|
+
label: `${props.showFlags && c.flag ? `${c.flag} ` : ""}${c.name}`,
|
|
35
|
+
icon: c.code === locale.value ? "i-lucide-check" : undefined,
|
|
36
|
+
onSelect: () => setLocale(c.code),
|
|
37
|
+
})),
|
|
38
|
+
])
|
|
39
|
+
|
|
40
|
+
const selectItems = computed(() =>
|
|
41
|
+
(localeConfigs.value || []).map((c) => ({
|
|
42
|
+
label: `${props.showFlags && c.flag ? `${c.flag} ` : ""}${c.name}`,
|
|
43
|
+
value: c.code,
|
|
44
|
+
})),
|
|
45
|
+
)
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<template v-if="localeConfigs && localeConfigs.length > 1">
|
|
50
|
+
<!-- Buttons variant -->
|
|
51
|
+
<div
|
|
52
|
+
v-if="variant === 'buttons'"
|
|
53
|
+
:class="['inline-flex items-center gap-1 rounded-lg border border-gray-200 dark:border-gray-800 p-1 bg-gray-50/50 dark:bg-gray-900/50 text-xs font-medium', props.class]"
|
|
54
|
+
role="group"
|
|
55
|
+
aria-label="Language switcher"
|
|
56
|
+
>
|
|
57
|
+
<UButton
|
|
58
|
+
v-for="c in localeConfigs"
|
|
59
|
+
:key="c.code"
|
|
60
|
+
:size="size"
|
|
61
|
+
:variant="c.code === locale ? 'solid' : 'ghost'"
|
|
62
|
+
:color="color"
|
|
63
|
+
:label="c.name"
|
|
64
|
+
:class="[
|
|
65
|
+
'flex items-center gap-1.5',
|
|
66
|
+
c.code === locale
|
|
67
|
+
? 'bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-xs font-semibold'
|
|
68
|
+
: 'text-gray-600 dark:text-gray-400',
|
|
69
|
+
]"
|
|
70
|
+
@click="setLocale(c.code)"
|
|
71
|
+
>
|
|
72
|
+
<template v-if="showFlags && c.flag" #leading>
|
|
73
|
+
<span class="text-sm leading-none">{{ c.flag }}</span>
|
|
74
|
+
</template>
|
|
75
|
+
</UButton>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<!-- Select variant: Nuxt UI USelect -->
|
|
79
|
+
<USelect
|
|
80
|
+
v-else-if="variant === 'select'"
|
|
81
|
+
:model-value="locale"
|
|
82
|
+
:items="selectItems"
|
|
83
|
+
:size="size"
|
|
84
|
+
:color="color"
|
|
85
|
+
variant="subtle"
|
|
86
|
+
:class="props.class"
|
|
87
|
+
@update:model-value="setLocale($event)"
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<!-- Dropdown variant (DEFAULT): Nuxt UI UDropdownMenu -->
|
|
91
|
+
<UDropdownMenu
|
|
92
|
+
v-else
|
|
93
|
+
:items="dropdownItems"
|
|
94
|
+
:content="{ align: 'start' }"
|
|
95
|
+
>
|
|
96
|
+
<UButton
|
|
97
|
+
:size="size"
|
|
98
|
+
variant="outline"
|
|
99
|
+
:color="color"
|
|
100
|
+
:label="activeConfig?.name"
|
|
101
|
+
trailing-icon="i-lucide-chevron-down"
|
|
102
|
+
:class="props.class"
|
|
103
|
+
>
|
|
104
|
+
<template v-if="showFlags && activeConfig?.flag" #leading>
|
|
105
|
+
<span class="text-sm leading-none">{{ activeConfig.flag }}</span>
|
|
106
|
+
</template>
|
|
107
|
+
</UButton>
|
|
108
|
+
</UDropdownMenu>
|
|
109
|
+
</template>
|
|
110
|
+
</template>
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed } from "vue"
|
|
3
|
-
import { useCMSPreview } from "../composables/cms-preview"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `<CMSPreviewBanner>` / `<DocsPreviewBanner>` — Warning banner displayed when a user
|
|
7
|
-
* is viewing an unpublished CMS entry in Preview Mode. Provides an expiry notice and
|
|
8
|
-
* a one-click button to exit preview mode.
|
|
9
|
-
*/
|
|
10
|
-
withDefaults(defineProps<{
|
|
11
|
-
class?: string
|
|
12
|
-
adminUrl?: string
|
|
13
|
-
}>(), {
|
|
14
|
-
class: "",
|
|
15
|
-
adminUrl: "/admin",
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const { isPreview, expires, disable } = useCMSPreview()
|
|
19
|
-
|
|
20
|
-
const remainingTime = computed(() => {
|
|
21
|
-
if (!expires.value) return null
|
|
22
|
-
const exp = Number(expires.value)
|
|
23
|
-
if (isNaN(exp)) return null
|
|
24
|
-
const diffMs = exp - Date.now()
|
|
25
|
-
if (diffMs <= 0) return "expired"
|
|
26
|
-
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
|
27
|
-
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
|
28
|
-
if (hours > 0) return `${hours}h ${minutes}m remaining`
|
|
29
|
-
return `${minutes}m remaining`
|
|
30
|
-
})
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<template>
|
|
34
|
-
<div
|
|
35
|
-
v-if="isPreview"
|
|
36
|
-
:class="[
|
|
37
|
-
'rounded-lg border border-amber-400/80 dark:border-amber-600/60 bg-amber-50/95 dark:bg-amber-950/40 p-3.5 text-xs text-amber-950 dark:text-amber-200 mb-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 shadow-xs',
|
|
38
|
-
$props.class,
|
|
39
|
-
]"
|
|
40
|
-
role="status"
|
|
41
|
-
aria-live="polite"
|
|
42
|
-
>
|
|
43
|
-
<div class="flex items-center gap-2.5 flex-wrap">
|
|
44
|
-
<UBadge
|
|
45
|
-
color="warning"
|
|
46
|
-
variant="solid"
|
|
47
|
-
size="xs"
|
|
48
|
-
class="text-[10px] font-bold tracking-wide uppercase"
|
|
49
|
-
label="Draft Preview"
|
|
50
|
-
/>
|
|
51
|
-
<span class="font-medium">You are viewing an unpublished preview.</span>
|
|
52
|
-
<span v-if="remainingTime" class="text-amber-800 dark:text-amber-300/80">
|
|
53
|
-
({{ remainingTime }})
|
|
54
|
-
</span>
|
|
55
|
-
</div>
|
|
56
|
-
<div class="flex items-center gap-2 shrink-0 w-full sm:w-auto justify-end">
|
|
57
|
-
<UButton
|
|
58
|
-
v-if="adminUrl"
|
|
59
|
-
:to="adminUrl"
|
|
60
|
-
size="xs"
|
|
61
|
-
color="warning"
|
|
62
|
-
variant="ghost"
|
|
63
|
-
class="font-semibold"
|
|
64
|
-
>
|
|
65
|
-
Open in CMS
|
|
66
|
-
</UButton>
|
|
67
|
-
<UButton
|
|
68
|
-
size="xs"
|
|
69
|
-
color="warning"
|
|
70
|
-
variant="subtle"
|
|
71
|
-
class="font-semibold"
|
|
72
|
-
trailing-icon="i-lucide-x"
|
|
73
|
-
@click="disable()"
|
|
74
|
-
>
|
|
75
|
-
Exit Preview
|
|
76
|
-
</UButton>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
import { useCMSPreview } from "../composables/cms-preview"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `<CMSPreviewBanner>` / `<DocsPreviewBanner>` — Warning banner displayed when a user
|
|
7
|
+
* is viewing an unpublished CMS entry in Preview Mode. Provides an expiry notice and
|
|
8
|
+
* a one-click button to exit preview mode.
|
|
9
|
+
*/
|
|
10
|
+
withDefaults(defineProps<{
|
|
11
|
+
class?: string
|
|
12
|
+
adminUrl?: string
|
|
13
|
+
}>(), {
|
|
14
|
+
class: "",
|
|
15
|
+
adminUrl: "/admin",
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const { isPreview, expires, disable } = useCMSPreview()
|
|
19
|
+
|
|
20
|
+
const remainingTime = computed(() => {
|
|
21
|
+
if (!expires.value) return null
|
|
22
|
+
const exp = Number(expires.value)
|
|
23
|
+
if (isNaN(exp)) return null
|
|
24
|
+
const diffMs = exp - Date.now()
|
|
25
|
+
if (diffMs <= 0) return "expired"
|
|
26
|
+
const hours = Math.floor(diffMs / (1000 * 60 * 60))
|
|
27
|
+
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60))
|
|
28
|
+
if (hours > 0) return `${hours}h ${minutes}m remaining`
|
|
29
|
+
return `${minutes}m remaining`
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div
|
|
35
|
+
v-if="isPreview"
|
|
36
|
+
:class="[
|
|
37
|
+
'rounded-lg border border-amber-400/80 dark:border-amber-600/60 bg-amber-50/95 dark:bg-amber-950/40 p-3.5 text-xs text-amber-950 dark:text-amber-200 mb-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 shadow-xs',
|
|
38
|
+
$props.class,
|
|
39
|
+
]"
|
|
40
|
+
role="status"
|
|
41
|
+
aria-live="polite"
|
|
42
|
+
>
|
|
43
|
+
<div class="flex items-center gap-2.5 flex-wrap">
|
|
44
|
+
<UBadge
|
|
45
|
+
color="warning"
|
|
46
|
+
variant="solid"
|
|
47
|
+
size="xs"
|
|
48
|
+
class="text-[10px] font-bold tracking-wide uppercase"
|
|
49
|
+
label="Draft Preview"
|
|
50
|
+
/>
|
|
51
|
+
<span class="font-medium">You are viewing an unpublished preview.</span>
|
|
52
|
+
<span v-if="remainingTime" class="text-amber-800 dark:text-amber-300/80">
|
|
53
|
+
({{ remainingTime }})
|
|
54
|
+
</span>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="flex items-center gap-2 shrink-0 w-full sm:w-auto justify-end">
|
|
57
|
+
<UButton
|
|
58
|
+
v-if="adminUrl"
|
|
59
|
+
:to="adminUrl"
|
|
60
|
+
size="xs"
|
|
61
|
+
color="warning"
|
|
62
|
+
variant="ghost"
|
|
63
|
+
class="font-semibold"
|
|
64
|
+
>
|
|
65
|
+
Open in CMS
|
|
66
|
+
</UButton>
|
|
67
|
+
<UButton
|
|
68
|
+
size="xs"
|
|
69
|
+
color="warning"
|
|
70
|
+
variant="subtle"
|
|
71
|
+
class="font-semibold"
|
|
72
|
+
trailing-icon="i-lucide-x"
|
|
73
|
+
@click="disable()"
|
|
74
|
+
>
|
|
75
|
+
Exit Preview
|
|
76
|
+
</UButton>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed } from "vue"
|
|
3
|
-
import { useDocsVersion } from "../composables/docs-version"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `<CMSVersionBanner>` / `<DocsVersionBanner>` — Warning banner displayed when a reader
|
|
7
|
-
* is viewing an archived or legacy documentation version. Provides a one-click link to
|
|
8
|
-
* the equivalent page in the latest version.
|
|
9
|
-
*/
|
|
10
|
-
withDefaults(defineProps<{
|
|
11
|
-
class?: string
|
|
12
|
-
}>(), {
|
|
13
|
-
class: "",
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const { isLatest, activeVersionItem, getVersionPath } = useDocsVersion()
|
|
17
|
-
const latestUrl = computed(() => getVersionPath("latest"))
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<template>
|
|
21
|
-
<div
|
|
22
|
-
v-if="!isLatest"
|
|
23
|
-
:class="[
|
|
24
|
-
'rounded-lg border border-amber-300/80 dark:border-amber-700/60 bg-amber-50/90 dark:bg-amber-950/30 p-3.5 text-xs text-amber-900 dark:text-amber-200 mb-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 shadow-xs',
|
|
25
|
-
$props.class,
|
|
26
|
-
]"
|
|
27
|
-
role="alert"
|
|
28
|
-
aria-live="polite"
|
|
29
|
-
>
|
|
30
|
-
<div class="flex items-center gap-2">
|
|
31
|
-
<span class="text-base leading-none">⚠️</span>
|
|
32
|
-
<span>
|
|
33
|
-
You are viewing archived documentation for
|
|
34
|
-
<strong class="font-semibold">{{ activeVersionItem.label }}</strong>.
|
|
35
|
-
This version may be outdated.
|
|
36
|
-
</span>
|
|
37
|
-
</div>
|
|
38
|
-
<UButton
|
|
39
|
-
:to="latestUrl"
|
|
40
|
-
size="xs"
|
|
41
|
-
color="warning"
|
|
42
|
-
variant="subtle"
|
|
43
|
-
class="shrink-0"
|
|
44
|
-
trailing-icon="i-lucide-arrow-right"
|
|
45
|
-
>
|
|
46
|
-
Switch to latest version
|
|
47
|
-
</UButton>
|
|
48
|
-
</div>
|
|
49
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
import { useDocsVersion } from "../composables/docs-version"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `<CMSVersionBanner>` / `<DocsVersionBanner>` — Warning banner displayed when a reader
|
|
7
|
+
* is viewing an archived or legacy documentation version. Provides a one-click link to
|
|
8
|
+
* the equivalent page in the latest version.
|
|
9
|
+
*/
|
|
10
|
+
withDefaults(defineProps<{
|
|
11
|
+
class?: string
|
|
12
|
+
}>(), {
|
|
13
|
+
class: "",
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const { isLatest, activeVersionItem, getVersionPath } = useDocsVersion()
|
|
17
|
+
const latestUrl = computed(() => getVersionPath("latest"))
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div
|
|
22
|
+
v-if="!isLatest"
|
|
23
|
+
:class="[
|
|
24
|
+
'rounded-lg border border-amber-300/80 dark:border-amber-700/60 bg-amber-50/90 dark:bg-amber-950/30 p-3.5 text-xs text-amber-900 dark:text-amber-200 mb-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 shadow-xs',
|
|
25
|
+
$props.class,
|
|
26
|
+
]"
|
|
27
|
+
role="alert"
|
|
28
|
+
aria-live="polite"
|
|
29
|
+
>
|
|
30
|
+
<div class="flex items-center gap-2">
|
|
31
|
+
<span class="text-base leading-none">⚠️</span>
|
|
32
|
+
<span>
|
|
33
|
+
You are viewing archived documentation for
|
|
34
|
+
<strong class="font-semibold">{{ activeVersionItem.label }}</strong>.
|
|
35
|
+
This version may be outdated.
|
|
36
|
+
</span>
|
|
37
|
+
</div>
|
|
38
|
+
<UButton
|
|
39
|
+
:to="latestUrl"
|
|
40
|
+
size="xs"
|
|
41
|
+
color="warning"
|
|
42
|
+
variant="subtle"
|
|
43
|
+
class="shrink-0"
|
|
44
|
+
trailing-icon="i-lucide-arrow-right"
|
|
45
|
+
>
|
|
46
|
+
Switch to latest version
|
|
47
|
+
</UButton>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|