undocs 0.2.0 → 0.2.2

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/bin/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env node
2
2
  import jiti from 'jiti'
3
3
 
4
4
  jiti(import.meta.url, { esmResolve: true })('../layers/unjs/cli/main.ts')
@@ -21,6 +21,7 @@ export default defineNuxtConfig({
21
21
  '@nuxtjs/seo',
22
22
  isProd && '@nuxtjs/plausible',
23
23
  '@nuxt/ui',
24
+ 'nuxt-build-cache',
24
25
  ],
25
26
  ui: {
26
27
  icons: [],
@@ -1,26 +1,37 @@
1
1
  export default defineNitroPlugin((nitroApp) => {
2
2
  nitroApp.hooks.hook('content:file:afterParse', (file) => {
3
- if (file._id.endsWith('.md')) {
4
- // Remove first h1 and p from markdown files as they are added to front-matter by default
5
- if (file.body?.children?.[0]?.tag === 'h1' && file.title === file.body.children[0].children?.[0]?.value) {
6
- file.body.children.shift()
7
- }
8
- if (file.body?.children?.[0]?.tag === 'p' && file.description === file.body.children[0].children?.[0]?.value) {
9
- file.body.children.shift()
10
- }
11
- // Handle GitHub flavoured markdown blockquotes
12
- // https://github.com/orgs/community/discussions/16925
13
- for (const node of file.body?.children || []) {
14
- if (
15
- node.tag === 'blockquote' && // bloquote > p x 2 > span > text
16
- ['!NOTE', '!TIP', '!IMPORTANT', '!WARNING', '!CAUTION'].includes(
17
- node.children?.[0]?.children?.[0]?.children?.[0]?.value,
18
- )
19
- ) {
20
- node.type = 'element'
21
- node.tag = node.children?.[0]?.children?.[0]?.children?.[0]?.value.slice(1).toLowerCase()
22
- node.children[0].children.shift()
23
- }
3
+ // Filter out non-markdown files
4
+ if (!file._id.endsWith('.md')) {
5
+ return
6
+ }
7
+
8
+ // Remove first h1 from markdown files as it is added to front-matter as title
9
+ if (file.body?.children?.[0]?.tag === 'h1' && file.title === file.body.children[0].children?.[0]?.value) {
10
+ file.body.children.shift()
11
+ }
12
+
13
+ // Only use the first blockquote as the description
14
+ const firstChild = file.body.children?.[0]
15
+ const firstChildContent = firstChild?.children?.[0]?.children?.[0]?.value
16
+ if (firstChild.tag === 'blockquote' && firstChildContent) {
17
+ file.description = firstChildContent
18
+ file.body.children.shift()
19
+ } else {
20
+ file.description = '' // Avoid duplication
21
+ }
22
+
23
+ // Handle GitHub flavoured markdown blockquotes
24
+ // https://github.com/orgs/community/discussions/16925
25
+ for (const node of file.body?.children || []) {
26
+ if (
27
+ node.tag === 'blockquote' && // bloquote > p x 2 > span > text
28
+ ['!NOTE', '!TIP', '!IMPORTANT', '!WARNING', '!CAUTION'].includes(
29
+ node.children?.[0]?.children?.[0]?.children?.[0]?.value,
30
+ )
31
+ ) {
32
+ node.type = 'element'
33
+ node.tag = node.children?.[0]?.children?.[0]?.children?.[0]?.value.slice(1).toLowerCase()
34
+ node.children[0].children.shift()
24
35
  }
25
36
  }
26
37
  })
@@ -25,7 +25,7 @@ export function createCLI(opts: DocsCLIOptions = {}) {
25
25
  },
26
26
  args: { ...sharedArgs },
27
27
  async setup({ args }) {
28
- const { appDir, nuxtConfig } = await setupDocs(args.dir, opts.setup)
28
+ const { appDir, nuxtConfig } = await setupDocs(args.dir, { ...opts.setup, dev: true })
29
29
  process.chdir(appDir)
30
30
  await import('nuxi').then((nuxi) =>
31
31
  nuxi.runCommand('dev', [appDir, '--no-fork', '--port', '4000'], { overrides: nuxtConfig }),
@@ -10,6 +10,7 @@ const pkgDir = fileURLToPath(new URL('../../..', import.meta.url))
10
10
 
11
11
  export interface SetupDocsOptions {
12
12
  defaults?: DocsConfig
13
+ dev?: boolean
13
14
  extends?: string[]
14
15
  }
15
16
 
@@ -21,7 +22,7 @@ export async function setupDocs(docsDir: string, opts: SetupDocsOptions = {}) {
21
22
  docsconfig.dir = docsDir = resolve(docsconfig.dir || docsDir)
22
23
 
23
24
  // URL is required for production build (SEO)
24
- if (!docsconfig.url) {
25
+ if (!docsconfig.url && !opts.dev) {
25
26
  throw new Error('`url` config is required for production build!')
26
27
  }
27
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undocs",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "repository": "unjs/undocs",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,24 +27,25 @@
27
27
  "undocs": "./bin/cli.mjs"
28
28
  },
29
29
  "dependencies": {
30
- "@nuxt/content": "^2.11.0",
30
+ "@nuxt/content": "^2.12.0",
31
31
  "@nuxt/ui": "^2.13.0",
32
32
  "@nuxt/ui-pro": "^0.7.5",
33
33
  "@nuxthq/studio": "^1.0.10",
34
34
  "@nuxtjs/fontaine": "^0.4.1",
35
35
  "@nuxtjs/google-fonts": "^3.1.3",
36
36
  "@nuxtjs/plausible": "^0.2.4",
37
- "@nuxtjs/seo": "^2.0.0-rc.7",
38
- "@nuxtjs/tailwindcss": "^6.11.2",
39
- "c12": "^1.6.1",
37
+ "@nuxtjs/seo": "^2.0.0-rc.8",
38
+ "@nuxtjs/tailwindcss": "^6.11.3",
39
+ "c12": "^1.7.0",
40
40
  "citty": "^0.1.5",
41
41
  "consola": "^3.2.3",
42
42
  "defu": "^6.1.4",
43
43
  "is-buffer": "^2.0.5",
44
44
  "nuxi": "^3.10.0",
45
- "nuxt": "^3.10.0",
45
+ "nuxt": "^3.10.1",
46
+ "nuxt-build-cache": "^0.1.1",
46
47
  "pkg-types": "^1.0.3",
47
- "scule": "^1.2.0",
48
+ "scule": "^1.3.0",
48
49
  "tailwindcss": "^3.4.1",
49
50
  "theme-colors": "^0.1.0",
50
51
  "unstorage": "^1.10.1",
@@ -58,9 +59,9 @@
58
59
  "eslint": "^8.56.0",
59
60
  "eslint-config-unjs": "^0.2.1",
60
61
  "jiti": "^1.21.0",
61
- "prettier": "^3.2.4",
62
+ "prettier": "^3.2.5",
62
63
  "typescript": "^5.3.3",
63
64
  "vue-tsc": "^1.8.27"
64
65
  },
65
- "packageManager": "bun@1.0.25"
66
- }
66
+ "packageManager": "bun@1.0.26"
67
+ }