docus 5.3.1 → 5.4.1

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/app/app.vue CHANGED
@@ -53,6 +53,7 @@ const { data: navigation } = await useAsyncData(() => `navigation_${collectionNa
53
53
  })
54
54
  const { data: files } = useLazyAsyncData(`search_${collectionName.value}`, () => queryCollectionSearchSections(collectionName.value as keyof PageCollections), {
55
55
  server: false,
56
+ watch: [locale],
56
57
  })
57
58
 
58
59
  provide('navigation', navigation)
@@ -1,4 +1,6 @@
1
1
  <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+
2
4
  const props = withDefaults(defineProps<{ title?: string, description?: string, headline?: string }>(), {
3
5
  title: 'title',
4
6
  description: 'description',
@@ -1,4 +1,6 @@
1
1
  <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+
2
4
  const props = withDefaults(defineProps<{ title?: string, description?: string, headline?: string }>(), {
3
5
  title: 'title',
4
6
  description: 'description',
@@ -1,12 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import { useClipboard } from '@vueuse/core'
3
+ import { useRuntimeConfig } from '#imports'
3
4
 
4
5
  const route = useRoute()
6
+ const appBaseURL = useRuntimeConfig().app?.baseURL || '/'
5
7
 
6
8
  const { copy, copied } = useClipboard()
7
9
  const { t } = useDocusI18n()
8
10
 
9
- const markdownLink = computed(() => `${window?.location?.origin}/raw${route.path}.md`)
11
+ const markdownLink = computed(() => `${window?.location?.origin}${appBaseURL}raw${route.path}.md`)
10
12
  const items = [
11
13
  {
12
14
  label: t('docs.copy.link'),
package/nuxt.config.ts CHANGED
@@ -11,6 +11,7 @@ export default defineNuxtConfig({
11
11
  '@nuxt/content',
12
12
  '@nuxt/image',
13
13
  '@nuxtjs/robots',
14
+ '@nuxtjs/mcp-toolkit',
14
15
  'nuxt-og-image',
15
16
  'nuxt-llms',
16
17
  () => {
@@ -43,6 +44,9 @@ export default defineNuxtConfig({
43
44
  },
44
45
  },
45
46
  },
47
+ experimental: {
48
+ asyncContext: true,
49
+ },
46
50
  compatibilityDate: '2025-07-22',
47
51
  nitro: {
48
52
  prerender: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docus",
3
3
  "description": "Nuxt layer for Docus documentation theme",
4
- "version": "5.3.1",
4
+ "version": "5.4.1",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
7
7
  "repository": {
@@ -22,16 +22,17 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@iconify-json/lucide": "^1.2.75",
26
- "@iconify-json/simple-icons": "^1.2.60",
27
- "@iconify-json/vscode-icons": "^1.2.36",
28
- "@nuxt/content": "^3.8.2",
25
+ "@iconify-json/lucide": "^1.2.81",
26
+ "@iconify-json/simple-icons": "^1.2.63",
27
+ "@iconify-json/vscode-icons": "^1.2.37",
28
+ "@nuxt/content": "^3.9.0",
29
29
  "@nuxt/image": "^2.0.0",
30
- "@nuxt/kit": "^4.2.1",
31
- "@nuxt/ui": "^4.2.1",
30
+ "@nuxt/kit": "^4.2.2",
31
+ "@nuxt/ui": "^4.3.0",
32
32
  "@nuxtjs/i18n": "^10.2.1",
33
- "@nuxtjs/mdc": "^0.18.4",
34
- "@nuxtjs/robots": "^5.5.6",
33
+ "@nuxtjs/mcp-toolkit": "^0.5.2",
34
+ "@nuxtjs/mdc": "^0.19.1",
35
+ "@nuxtjs/robots": "^5.6.7",
35
36
  "@vueuse/core": "^13.9.0",
36
37
  "defu": "^6.1.4",
37
38
  "exsolve": "^1.0.8",
@@ -39,11 +40,13 @@
39
40
  "minimark": "^0.2.0",
40
41
  "motion-v": "^1.7.4",
41
42
  "nuxt-llms": "^0.1.3",
42
- "nuxt-og-image": "^5.1.12",
43
+ "nuxt-og-image": "^5.1.13",
43
44
  "pkg-types": "^2.3.0",
44
45
  "scule": "^1.3.0",
45
- "tailwindcss": "^4.1.17",
46
- "ufo": "^1.6.1"
46
+ "tailwindcss": "^4.1.18",
47
+ "ufo": "^1.6.1",
48
+ "zod": "^4.2.1",
49
+ "zod-to-json-schema": "^3.25.0"
47
50
  },
48
51
  "peerDependencies": {
49
52
  "better-sqlite3": "12.x",
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod'
2
+ import { queryCollection } from '@nuxt/content/server'
3
+ import type { Collections } from '@nuxt/content'
4
+ import { getAvailableLocales, getCollectionFromPath } from '../../utils/content'
5
+ import { inferSiteURL } from '../../../utils/meta'
6
+
7
+ export default defineMcpTool({
8
+ description: `Retrieves the full content and details of a specific documentation page.
9
+
10
+ WHEN TO USE: Use this tool when you know the EXACT path to a documentation page. Common use cases:
11
+ - User asks for a specific page: "Show me the getting started guide" → /en/getting-started/installation
12
+ - User asks about a known topic with a dedicated page
13
+ - You found a relevant path from list-pages and want the full content
14
+ - User references a specific section or guide they want to read
15
+
16
+ WHEN NOT TO USE: If you don't know the exact path and need to search/explore, use list-pages first.
17
+
18
+ WORKFLOW: This tool returns the complete page content including title, description, and full markdown. Use this when you need to provide detailed answers or code examples from specific documentation pages.
19
+ `,
20
+ inputSchema: {
21
+ path: z.string().describe('The page path from list-pages or provided by the user (e.g., /en/getting-started/installation)'),
22
+ },
23
+ cache: '1h',
24
+ handler: async ({ path }) => {
25
+ const event = useEvent()
26
+ const config = useRuntimeConfig(event).public
27
+ const siteUrl = import.meta.dev ? 'http://localhost:3000' : inferSiteURL()
28
+
29
+ const availableLocales = getAvailableLocales(config)
30
+ const collectionName = config.i18n?.locales
31
+ ? getCollectionFromPath(path, availableLocales)
32
+ : 'docs'
33
+
34
+ try {
35
+ const page = await queryCollection(event, collectionName as keyof Collections)
36
+ .where('path', '=', path)
37
+ .select('title', 'path', 'description')
38
+ .first()
39
+
40
+ if (!page) {
41
+ return errorResult('Page not found')
42
+ }
43
+
44
+ const content = await $fetch<string>(`/raw${path}.md`, {
45
+ baseURL: siteUrl,
46
+ })
47
+
48
+ return jsonResult({
49
+ title: page.title,
50
+ path: page.path,
51
+ description: page.description,
52
+ content,
53
+ url: `${siteUrl}${page.path}`,
54
+ })
55
+ }
56
+ catch {
57
+ return errorResult('Failed to get page')
58
+ }
59
+ },
60
+ })
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod'
2
+ import { queryCollection } from '@nuxt/content/server'
3
+ import type { Collections } from '@nuxt/content'
4
+ import { getCollectionsToQuery, getAvailableLocales } from '../../utils/content'
5
+
6
+ export default defineMcpTool({
7
+ description: `Lists all available documentation pages with their categories and basic information.
8
+
9
+ WHEN TO USE: Use this tool when you need to EXPLORE or SEARCH for documentation about a topic but don't know the exact page path. Common scenarios:
10
+ - "Find documentation about markdown features" - explore available guides
11
+ - "Show me all getting started guides" - browse introductory content
12
+ - "Search for advanced configuration options" - find specific topics
13
+ - User asks general questions without specifying exact pages
14
+ - You need to understand the overall documentation structure
15
+
16
+ WHEN NOT TO USE: If you already know the specific page path (e.g., "/en/getting-started/installation"), use get-page directly instead.
17
+
18
+ WORKFLOW: This tool returns page titles, descriptions, and paths. After finding relevant pages, use get-page to retrieve the full content of specific pages that match the user's needs.
19
+
20
+ OUTPUT: Returns a structured list with:
21
+ - title: Human-readable page name
22
+ - path: Exact path for use with get-page
23
+ - description: Brief summary of page content
24
+ - url: Full URL for reference`,
25
+ inputSchema: {
26
+ locale: z.string().optional().describe('The locale to filter pages by'),
27
+ },
28
+ cache: '1h',
29
+ handler: async ({ locale }) => {
30
+ const event = useEvent()
31
+ const config = useRuntimeConfig(event).public
32
+
33
+ const siteUrl = import.meta.dev ? 'http://localhost:3000' : getRequestURL(event).origin
34
+ const availableLocales = getAvailableLocales(config)
35
+ const collections = getCollectionsToQuery(locale, availableLocales)
36
+
37
+ try {
38
+ const allPages = await Promise.all(
39
+ collections.map(async (collectionName) => {
40
+ const pages = await queryCollection(event, collectionName as keyof Collections)
41
+ .select('title', 'path', 'description')
42
+ .all()
43
+
44
+ return pages.map(page => ({
45
+ title: page.title,
46
+ path: page.path,
47
+ description: page.description,
48
+ locale: collectionName.replace('docs_', ''),
49
+ url: `${siteUrl}${page.path}`,
50
+ }))
51
+ }),
52
+ )
53
+
54
+ return jsonResult(allPages.flat())
55
+ }
56
+ catch {
57
+ return errorResult('Failed to list pages')
58
+ }
59
+ },
60
+ })
@@ -1,6 +1,6 @@
1
1
  import { withLeadingSlash } from 'ufo'
2
2
  import { stringify } from 'minimark/stringify'
3
- import { queryCollection } from '@nuxt/content/nitro'
3
+ import { queryCollection } from '@nuxt/content/server'
4
4
  import type { Collections } from '@nuxt/content'
5
5
 
6
6
  export default eventHandler(async (event) => {
@@ -0,0 +1,37 @@
1
+ import type { LocaleObject } from '@nuxtjs/i18n'
2
+
3
+ type ConfigWithLocales = {
4
+ i18n?: { locales?: Array<string | LocaleObject> }
5
+ docus?: { filteredLocales?: LocaleObject<string>[] }
6
+ }
7
+
8
+ export function getAvailableLocales(config: ConfigWithLocales): string[] {
9
+ if (config.docus?.filteredLocales) {
10
+ return config.docus.filteredLocales.map(locale => locale.code)
11
+ }
12
+
13
+ return config.i18n?.locales
14
+ ? config.i18n.locales.map(locale => typeof locale === 'string' ? locale : locale.code)
15
+ : []
16
+ }
17
+
18
+ export function getCollectionsToQuery(locale: string | undefined, availableLocales: string[]): string[] {
19
+ if (locale && availableLocales.includes(locale)) {
20
+ return [`docs_${locale}`]
21
+ }
22
+
23
+ return availableLocales.length > 0
24
+ ? availableLocales.map(l => `docs_${l}`)
25
+ : ['docs']
26
+ }
27
+
28
+ export function getCollectionFromPath(path: string, availableLocales: string[]): string {
29
+ const pathSegments = path.split('/').filter(Boolean)
30
+ const firstSegment = pathSegments[0]
31
+
32
+ if (firstSegment && availableLocales.includes(firstSegment)) {
33
+ return `docs_${firstSegment}`
34
+ }
35
+
36
+ return 'docs'
37
+ }