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.
@@ -1,140 +1,140 @@
1
- <script lang="ts" setup>
2
- import { computed } from "vue"
3
- import { useDocsVersion } from "../composables/docs-version"
4
-
5
- /**
6
- * `<CMSVersionSwitcher>` / `<DocsVersionSwitcher>` — Polished Nuxt UI component for switching
7
- * between documentation versions. Preserves the active subpath when switching.
8
- */
9
- const props = withDefaults(
10
- defineProps<{
11
- variant?: "dropdown" | "select" | "buttons" | "badge"
12
- size?: "xs" | "sm" | "md"
13
- color?: "primary" | "neutral" | "secondary"
14
- class?: string
15
- repo?: string
16
- }>(),
17
- {
18
- variant: "dropdown",
19
- size: "xs",
20
- color: "primary",
21
- class: "",
22
- repo: "qarpeo/qarpeo",
23
- },
24
- )
25
-
26
- const { currentVersion, versions, switchVersion } = useDocsVersion()
27
-
28
- const currentLabel = computed(() => {
29
- const item = versions.value?.find((v) => v.id === currentVersion.value)
30
- if (item?.label) return item.label
31
- return currentVersion.value === "latest" ? "latest" : currentVersion.value
32
- })
33
-
34
- const releaseNotesUrl = computed(() => {
35
- const raw = currentVersion.value === "latest" ? currentLabel.value : currentVersion.value
36
- const clean = (raw || "").replace(/^v/, "").trim()
37
- if (clean && /^\d+\.\d+/.test(clean)) {
38
- return `https://github.com/${props.repo}/releases/tag/v${clean}`
39
- }
40
- return `https://github.com/${props.repo}/releases`
41
- })
42
-
43
- const dropdownItems = computed(() => [
44
- (versions.value || []).map((v) => ({
45
- label: v.label,
46
- icon: v.id === currentVersion.value ? "i-lucide-check" : undefined,
47
- badge: v.isLatest ? "latest" : v.isArchived ? "legacy" : undefined,
48
- onSelect: () => switchVersion(v.id),
49
- })),
50
- ])
51
-
52
- const selectItems = computed(() =>
53
- (versions.value || []).map((v) => ({
54
- label: v.label + (v.isArchived ? " (legacy)" : ""),
55
- value: v.id,
56
- })),
57
- )
58
- </script>
59
-
60
- <template>
61
- <template v-if="versions && versions.length > 1">
62
- <!-- Buttons variant -->
63
- <div
64
- v-if="variant === 'buttons'"
65
- :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]"
66
- role="group"
67
- aria-label="Documentation version switcher"
68
- >
69
- <UButton
70
- v-for="v in versions"
71
- :key="v.id"
72
- :size="size"
73
- variant="ghost"
74
- :color="color"
75
- :label="v.label"
76
- :class="[
77
- 'flex items-center gap-1.5 transition-colors',
78
- v.id === currentVersion
79
- ? 'bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-xs font-semibold'
80
- : 'text-gray-600 dark:text-gray-400',
81
- ]"
82
- @click="switchVersion(v.id)"
83
- >
84
- <template v-if="v.isLatest" #trailing>
85
- <UBadge
86
- size="xs"
87
- :color="color"
88
- variant="subtle"
89
- class="text-[10px] font-semibold"
90
- label="latest"
91
- />
92
- </template>
93
- </UButton>
94
- </div>
95
-
96
- <!-- Select variant: Nuxt UI USelect -->
97
- <USelect
98
- v-else-if="variant === 'select'"
99
- :model-value="currentVersion"
100
- :items="selectItems"
101
- :size="size"
102
- :color="color"
103
- variant="subtle"
104
- class="font-mono"
105
- :class="props.class"
106
- @update:model-value="switchVersion($event)"
107
- />
108
-
109
- <!-- Dropdown variant (DEFAULT): Nuxt UI UDropdownMenu with subtle button trigger -->
110
- <UDropdownMenu
111
- v-else
112
- :items="dropdownItems"
113
- :content="{ align: 'start' }"
114
- >
115
- <UButton
116
- :size="size"
117
- :color="color"
118
- variant="subtle"
119
- class="font-mono cursor-pointer"
120
- trailing-icon="i-lucide-chevron-down"
121
- :class="props.class"
122
- :label="currentLabel"
123
- />
124
- </UDropdownMenu>
125
- </template>
126
-
127
- <!-- Single version or loading fallback: interactive Nuxt UI UButton linking to release notes -->
128
- <UButton
129
- v-else
130
- :label="currentLabel"
131
- :aria-label="`Open ${currentLabel} release notes on GitHub`"
132
- variant="subtle"
133
- :size="size"
134
- :color="color"
135
- :to="releaseNotesUrl"
136
- target="_blank"
137
- class="font-semibold text-xs cursor-pointer hover:bg-primary/10 active:bg-primary/10 transition-colors"
138
- :class="props.class"
139
- />
140
- </template>
1
+ <script lang="ts" setup>
2
+ import { computed } from "vue"
3
+ import { useDocsVersion } from "../composables/docs-version"
4
+
5
+ /**
6
+ * `<CMSVersionSwitcher>` / `<DocsVersionSwitcher>` — Polished Nuxt UI component for switching
7
+ * between documentation versions. Preserves the active subpath when switching.
8
+ */
9
+ const props = withDefaults(
10
+ defineProps<{
11
+ variant?: "dropdown" | "select" | "buttons" | "badge"
12
+ size?: "xs" | "sm" | "md"
13
+ color?: "primary" | "neutral" | "secondary"
14
+ class?: string
15
+ repo?: string
16
+ }>(),
17
+ {
18
+ variant: "dropdown",
19
+ size: "xs",
20
+ color: "primary",
21
+ class: "",
22
+ repo: "qarpeo/qarpeo",
23
+ },
24
+ )
25
+
26
+ const { currentVersion, versions, switchVersion } = useDocsVersion()
27
+
28
+ const currentLabel = computed(() => {
29
+ const item = versions.value?.find((v) => v.id === currentVersion.value)
30
+ if (item?.label) return item.label
31
+ return currentVersion.value === "latest" ? "latest" : currentVersion.value
32
+ })
33
+
34
+ const releaseNotesUrl = computed(() => {
35
+ const raw = currentVersion.value === "latest" ? currentLabel.value : currentVersion.value
36
+ const clean = (raw || "").replace(/^v/, "").trim()
37
+ if (clean && /^\d+\.\d+/.test(clean)) {
38
+ return `https://github.com/${props.repo}/releases/tag/v${clean}`
39
+ }
40
+ return `https://github.com/${props.repo}/releases`
41
+ })
42
+
43
+ const dropdownItems = computed(() => [
44
+ (versions.value || []).map((v) => ({
45
+ label: v.label,
46
+ icon: v.id === currentVersion.value ? "i-lucide-check" : undefined,
47
+ badge: v.isLatest ? "latest" : v.isArchived ? "legacy" : undefined,
48
+ onSelect: () => switchVersion(v.id),
49
+ })),
50
+ ])
51
+
52
+ const selectItems = computed(() =>
53
+ (versions.value || []).map((v) => ({
54
+ label: v.label + (v.isArchived ? " (legacy)" : ""),
55
+ value: v.id,
56
+ })),
57
+ )
58
+ </script>
59
+
60
+ <template>
61
+ <template v-if="versions && versions.length > 1">
62
+ <!-- Buttons variant -->
63
+ <div
64
+ v-if="variant === 'buttons'"
65
+ :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]"
66
+ role="group"
67
+ aria-label="Documentation version switcher"
68
+ >
69
+ <UButton
70
+ v-for="v in versions"
71
+ :key="v.id"
72
+ :size="size"
73
+ variant="ghost"
74
+ :color="color"
75
+ :label="v.label"
76
+ :class="[
77
+ 'flex items-center gap-1.5 transition-colors',
78
+ v.id === currentVersion
79
+ ? 'bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-xs font-semibold'
80
+ : 'text-gray-600 dark:text-gray-400',
81
+ ]"
82
+ @click="switchVersion(v.id)"
83
+ >
84
+ <template v-if="v.isLatest" #trailing>
85
+ <UBadge
86
+ size="xs"
87
+ :color="color"
88
+ variant="subtle"
89
+ class="text-[10px] font-semibold"
90
+ label="latest"
91
+ />
92
+ </template>
93
+ </UButton>
94
+ </div>
95
+
96
+ <!-- Select variant: Nuxt UI USelect -->
97
+ <USelect
98
+ v-else-if="variant === 'select'"
99
+ :model-value="currentVersion"
100
+ :items="selectItems"
101
+ :size="size"
102
+ :color="color"
103
+ variant="subtle"
104
+ class="font-mono"
105
+ :class="props.class"
106
+ @update:model-value="switchVersion($event)"
107
+ />
108
+
109
+ <!-- Dropdown variant (DEFAULT): Nuxt UI UDropdownMenu with subtle button trigger -->
110
+ <UDropdownMenu
111
+ v-else
112
+ :items="dropdownItems"
113
+ :content="{ align: 'start' }"
114
+ >
115
+ <UButton
116
+ :size="size"
117
+ :color="color"
118
+ variant="subtle"
119
+ class="font-mono cursor-pointer"
120
+ trailing-icon="i-lucide-chevron-down"
121
+ :class="props.class"
122
+ :label="currentLabel"
123
+ />
124
+ </UDropdownMenu>
125
+ </template>
126
+
127
+ <!-- Single version or loading fallback: interactive Nuxt UI UButton linking to release notes -->
128
+ <UButton
129
+ v-else
130
+ :label="currentLabel"
131
+ :aria-label="`Open ${currentLabel} release notes on GitHub`"
132
+ variant="subtle"
133
+ :size="size"
134
+ :color="color"
135
+ :to="releaseNotesUrl"
136
+ target="_blank"
137
+ class="font-semibold text-xs cursor-pointer hover:bg-primary/10 active:bg-primary/10 transition-colors"
138
+ :class="props.class"
139
+ />
140
+ </template>
@@ -1,80 +1,80 @@
1
- <script lang="ts" setup>
2
- import { computed, shallowRef, watchEffect } from "vue"
3
- import { MarkdownDocument } from "@comark/vue"
4
- import { isMarkdownDocument } from "comark/utils"
5
- import { createSerializedMarkdownParser } from "comark"
6
-
7
- /**
8
- * `<ContentRenderer>` — Renders a CMS content value (Comark AST, raw markdown string, or page object).
9
- * Pre-parsed server ASTs are rendered instantly with zero client-side Shiki overhead.
10
- */
11
- const props = withDefaults(defineProps<{
12
- value?: object | string | null
13
- excerpt?: boolean
14
- tag?: string | boolean
15
- as?: string | boolean
16
- class?: string | any[] | Record<string, boolean>
17
- unwrap?: boolean | string | any[]
18
- components?: Record<string, any>
19
- plugins?: any[]
20
- }>(), {
21
- value: null,
22
- excerpt: false,
23
- tag: "div",
24
- class: "",
25
- unwrap: false,
26
- components: () => ({}),
27
- plugins: () => [],
28
- })
29
-
30
- const resolvedValue = computed(() => {
31
- const val = props.value as any
32
- if (!val) return ""
33
- if (isMarkdownDocument(val)) return val
34
- if (isMarkdownDocument(val.body)) return val.body
35
- if (typeof val.contentMd === "string" && val.contentMd) return val.contentMd
36
- if (typeof val.body === "string" && val.body) return val.body
37
- if (typeof val.body?.value === "string") return val.body.value
38
- if (typeof val.body?.content === "string") return val.body.content
39
- return ""
40
- })
41
-
42
- // Lazily-created parser (avoids importing Shiki on the client)
43
- let _parser: ReturnType<typeof createSerializedMarkdownParser> | null = null
44
- function getParser() {
45
- if (!_parser) {
46
- _parser = createSerializedMarkdownParser({ plugins: (props.plugins as any[]) || [] })
47
- }
48
- return _parser
49
- }
50
-
51
- const parsedDoc = shallowRef<any>(null)
52
-
53
- watchEffect(() => {
54
- const content = resolvedValue.value
55
- if (typeof content === "string" && content) {
56
- const raw = props.excerpt ? content.split("<!-- more -->")[0] : content
57
- getParser()(raw.trim(), { streaming: false }).then((doc) => {
58
- parsedDoc.value = doc
59
- })
60
- } else {
61
- parsedDoc.value = null
62
- }
63
- })
64
- </script>
65
-
66
- <template>
67
- <slot v-if="!resolvedValue" name="empty" />
68
- <MarkdownDocument
69
- v-else-if="isMarkdownDocument(resolvedValue)"
70
- :value="(resolvedValue as any)"
71
- :components="components"
72
- :class="class"
73
- />
74
- <MarkdownDocument
75
- v-else
76
- :value="parsedDoc ?? { nodes: [], frontmatter: {}, meta: {} }"
77
- :components="components"
78
- :class="class"
79
- />
80
- </template>
1
+ <script lang="ts" setup>
2
+ import { computed, shallowRef, watchEffect } from "vue"
3
+ import { MarkdownDocument } from "@comark/vue"
4
+ import { isMarkdownDocument } from "comark/utils"
5
+ import { createSerializedMarkdownParser } from "comark"
6
+
7
+ /**
8
+ * `<ContentRenderer>` — Renders a CMS content value (Comark AST, raw markdown string, or page object).
9
+ * Pre-parsed server ASTs are rendered instantly with zero client-side Shiki overhead.
10
+ */
11
+ const props = withDefaults(defineProps<{
12
+ value?: object | string | null
13
+ excerpt?: boolean
14
+ tag?: string | boolean
15
+ as?: string | boolean
16
+ class?: string | any[] | Record<string, boolean>
17
+ unwrap?: boolean | string | any[]
18
+ components?: Record<string, any>
19
+ plugins?: any[]
20
+ }>(), {
21
+ value: null,
22
+ excerpt: false,
23
+ tag: "div",
24
+ class: "",
25
+ unwrap: false,
26
+ components: () => ({}),
27
+ plugins: () => [],
28
+ })
29
+
30
+ const resolvedValue = computed(() => {
31
+ const val = props.value as any
32
+ if (!val) return ""
33
+ if (isMarkdownDocument(val)) return val
34
+ if (isMarkdownDocument(val.body)) return val.body
35
+ if (typeof val.contentMd === "string" && val.contentMd) return val.contentMd
36
+ if (typeof val.body === "string" && val.body) return val.body
37
+ if (typeof val.body?.value === "string") return val.body.value
38
+ if (typeof val.body?.content === "string") return val.body.content
39
+ return ""
40
+ })
41
+
42
+ // Lazily-created parser (avoids importing Shiki on the client)
43
+ let _parser: ReturnType<typeof createSerializedMarkdownParser> | null = null
44
+ function getParser() {
45
+ if (!_parser) {
46
+ _parser = createSerializedMarkdownParser({ plugins: (props.plugins as any[]) || [] })
47
+ }
48
+ return _parser
49
+ }
50
+
51
+ const parsedDoc = shallowRef<any>(null)
52
+
53
+ watchEffect(() => {
54
+ const content = resolvedValue.value
55
+ if (typeof content === "string" && content) {
56
+ const raw = props.excerpt ? content.split("<!-- more -->")[0] : content
57
+ getParser()(raw.trim(), { streaming: false }).then((doc) => {
58
+ parsedDoc.value = doc
59
+ })
60
+ } else {
61
+ parsedDoc.value = null
62
+ }
63
+ })
64
+ </script>
65
+
66
+ <template>
67
+ <slot v-if="!resolvedValue" name="empty" />
68
+ <MarkdownDocument
69
+ v-else-if="isMarkdownDocument(resolvedValue)"
70
+ :value="(resolvedValue as any)"
71
+ :components="components"
72
+ :class="class"
73
+ />
74
+ <MarkdownDocument
75
+ v-else
76
+ :value="parsedDoc ?? { nodes: [], frontmatter: {}, meta: {} }"
77
+ :components="components"
78
+ :class="class"
79
+ />
80
+ </template>