@movk/nuxt-docs 1.3.6 → 1.3.7

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,8 +1,34 @@
1
1
  <script setup lang="ts">
2
2
  import type { ComponentMeta } from 'vue-component-meta'
3
- import { camelCase, kebabCase } from 'scule'
3
+ import { camelCase, kebabCase, upperFirst } from 'scule'
4
4
 
5
- const { ignore = [], slug } = defineProps<{
5
+ const { ignore = [
6
+ 'activeClass',
7
+ 'inactiveClass',
8
+ 'exactActiveClass',
9
+ 'ariaCurrentValue',
10
+ 'href',
11
+ 'rel',
12
+ 'noRel',
13
+ 'prefetch',
14
+ 'prefetchOn',
15
+ 'noPrefetch',
16
+ 'prefetchedClass',
17
+ 'replace',
18
+ 'exact',
19
+ 'exactQuery',
20
+ 'exactHash',
21
+ 'external',
22
+ 'onClick',
23
+ 'viewTransition',
24
+ 'enterKeyHint',
25
+ 'form',
26
+ 'formaction',
27
+ 'formenctype',
28
+ 'formmethod',
29
+ 'formnovalidate',
30
+ 'formtarget'
31
+ ], slug, prose } = defineProps<{
6
32
  /**
7
33
  * The slug of the component to fetch props for.
8
34
  * @defaultValue route path's last segment
@@ -12,11 +38,12 @@ const { ignore = [], slug } = defineProps<{
12
38
  * An array of prop names to ignore.
13
39
  */
14
40
  ignore?: string[]
41
+ prose?: boolean
15
42
  }>()
16
43
 
17
44
  const route = useRoute()
18
-
19
- const componentName = camelCase(slug ?? route.path.split('/').pop() ?? '')
45
+ const camelName = camelCase(slug ?? route.path.split('/').pop() ?? '')
46
+ const componentName = prose ? `Prose${upperFirst(camelName)}` : `${upperFirst(camelName)}`
20
47
  const meta = await fetchComponentMeta(componentName as any)
21
48
 
22
49
  const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
@@ -22,18 +22,24 @@ function getSchemaProps(schema: PropertyMeta['schema']): any {
22
22
  }
23
23
 
24
24
  const schemaProps = computed(() => {
25
- return getSchemaProps(props.prop.schema).map((prop: any) => {
26
- const defaultValue = prop.default ?? prop.tags?.find((tag: any) => tag.name === 'defaultValue')?.text
27
- let description = prop.description
28
- if (defaultValue) {
29
- description = description ? `${description} Defaults to \`${defaultValue}\`{lang="ts-type"}.` : `Defaults to \`${defaultValue}\`{lang="ts-type"}.`
25
+ const propsObject = getSchemaProps(props.prop.schema).reduce((acc: any, prop: any) => {
26
+ if (!acc[prop.name]) {
27
+ const defaultValue = prop.default ?? prop.tags?.find((tag: any) => tag.name === 'defaultValue')?.text
28
+ let description = prop.description
29
+ if (defaultValue) {
30
+ description = description ? `${description} Defaults to \`${defaultValue}\`{lang="ts-type"}.` : `Defaults to \`${defaultValue}\`{lang="ts-type"}.`
31
+ }
32
+
33
+ acc[prop.name] = {
34
+ ...prop,
35
+ description
36
+ }
30
37
  }
31
38
 
32
- return {
33
- ...prop,
34
- description
35
- }
36
- })
39
+ return acc
40
+ }, {})
41
+
42
+ return Object.values(propsObject) as PropertyMeta[]
37
43
  })
38
44
  </script>
39
45
 
@@ -1,6 +1,4 @@
1
1
  <script setup lang="ts">
2
- import { hash } from 'ohash'
3
-
4
2
  const props = defineProps<{
5
3
  type: string
6
4
  }>()
@@ -23,9 +21,16 @@ const type = computed(() => {
23
21
  return type
24
22
  })
25
23
 
26
- const { data: ast } = await useAsyncData(`hightlight-inline-code-${hash(type.value).slice(0, 10)}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`))
24
+ const ast = ref<any>(null)
25
+
26
+ onMounted(async () => {
27
+ ast.value = await parseMarkdown(`\`${type.value}\`{lang="ts-type"}`)
28
+ })
27
29
  </script>
28
30
 
29
31
  <template>
30
32
  <MDCRenderer v-if="ast" :body="ast.body" :data="ast.data" />
33
+ <ProseCode v-else>
34
+ {{ type }}
35
+ </ProseCode>
31
36
  </template>
package/modules/config.ts CHANGED
@@ -70,8 +70,8 @@ export default defineNuxtModule({
70
70
  metaFields: {
71
71
  type: false,
72
72
  props: true,
73
- slots: true,
74
- events: true,
73
+ slots: 'no-schema' as const,
74
+ events: 'no-schema' as const,
75
75
  exposed: false
76
76
  }
77
77
  })
package/nuxt.config.ts CHANGED
@@ -8,7 +8,6 @@ export default defineNuxtConfig({
8
8
  resolve('./modules/config'),
9
9
  resolve('./modules/css'),
10
10
  resolve('./modules/component-example'),
11
- resolve('./modules/component-meta'),
12
11
  resolve('./modules/llms'),
13
12
  '@nuxt/ui',
14
13
  '@nuxt/content',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@movk/nuxt-docs",
3
3
  "type": "module",
4
- "version": "1.3.6",
4
+ "version": "1.3.7",
5
5
  "private": false,
6
6
  "description": "An elegant documentation theme for Nuxt, powered by Nuxt UI and Nuxt Content.",
7
7
  "author": "YiXuan <mhaibaraai@gmail.com>",
@@ -27,8 +27,8 @@
27
27
  "README.md"
28
28
  ],
29
29
  "dependencies": {
30
- "@iconify-json/lucide": "^1.2.74",
31
- "@iconify-json/simple-icons": "^1.2.59",
30
+ "@iconify-json/lucide": "^1.2.75",
31
+ "@iconify-json/simple-icons": "^1.2.60",
32
32
  "@iconify-json/vscode-icons": "^1.2.36",
33
33
  "@movk/core": "^1.0.1",
34
34
  "@nuxt/content": "^3.8.2",
@@ -1,27 +0,0 @@
1
- import { defineNuxtModule } from '@nuxt/kit'
2
- import type { NuxtComponentMeta } from 'nuxt-component-meta'
3
-
4
- export default defineNuxtModule({
5
- meta: {
6
- name: 'component-meta'
7
- },
8
- async setup(_options, nuxt) {
9
- // @ts-expect-error - Hook is not typed correctly
10
- nuxt.hook('component-meta:schema', (schema: NuxtComponentMeta) => {
11
- for (const componentName in schema) {
12
- const component = schema[componentName]
13
- // Delete schema from slots to reduce metadata file size
14
- if (component?.meta?.slots) {
15
- for (const slot of component.meta.slots) {
16
- delete (slot as any).schema
17
- }
18
- }
19
- if (component?.meta?.events) {
20
- for (const event of component.meta.events) {
21
- delete (event as any).schema
22
- }
23
- }
24
- }
25
- })
26
- }
27
- })