docus 4.0.0-beta.9 → 4.0.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/README.md CHANGED
@@ -14,6 +14,7 @@ This is the official Nuxt layer for [Docus](https://docus.dev), providing a comp
14
14
  - ✨ **Beautiful Design** - Clean, modern documentation theme
15
15
  - 📱 **Responsive** - Mobile-first responsive design
16
16
  - 🌙 **Dark Mode** - Built-in dark/light mode support
17
+ - 🌍 **Internationalization** - Native i18n support with automatic routing and language switching
17
18
  - 🔍 **Search** - Full-text search functionality
18
19
  - 📝 **Markdown Enhanced** - Extended markdown with custom components
19
20
  - 🎨 **Customizable** - Easy theming and customization
@@ -35,7 +36,7 @@ The easiest way to get started is using the Docus CLI, which automatically sets
35
36
 
36
37
  ```bash
37
38
  # Create a new documentation project
38
- npx create docus my-docs
39
+ npx create-docus my-docs
39
40
 
40
41
  # Navigate to your project
41
42
  cd my-docs
@@ -46,6 +47,13 @@ npm run dev
46
47
 
47
48
  This creates a complete documentation project pre-configured with `docus`.
48
49
 
50
+ For multi-language documentation, use the i18n template:
51
+
52
+ ```bash
53
+ # Create a new i18n documentation project
54
+ npx create-docus my-docs -t i18n
55
+ ```
56
+
49
57
  ### Option 2: Manual Setup
50
58
 
51
59
  #### Option 2a: Nuxt Config (recommended)
@@ -58,6 +66,21 @@ export default defineNuxtConfig({
58
66
  })
59
67
  ```
60
68
 
69
+ For internationalization, also add the `@nuxtjs/i18n` module:
70
+
71
+ ```typescript
72
+ export default defineNuxtConfig({
73
+ modules: ['@nuxtjs/i18n'],
74
+ i18n: {
75
+ defaultLocale: 'en',
76
+ locales: [
77
+ { code: 'en', name: 'English' },
78
+ { code: 'fr', name: 'Français' },
79
+ ],
80
+ }
81
+ })
82
+ ```
83
+
61
84
  #### Option 2b: CLI Usage
62
85
 
63
86
  Use directly with Nuxt CLI:
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { useDocusI18n } from '~/composables/useDocusI18n'
2
+ import { useDocusI18n } from '../../composables/useDocusI18n'
3
3
 
4
4
  const appConfig = useAppConfig()
5
5
  const site = useSiteConfig()
@@ -7,7 +7,6 @@ const { copy, copied } = useClipboard()
7
7
  const { t } = useDocusI18n()
8
8
 
9
9
  const markdownLink = computed(() => `${window?.location?.origin}/raw${route.path}.md`)
10
-
11
10
  const items = [
12
11
  {
13
12
  label: 'Copy Markdown link',
@@ -41,6 +40,11 @@ const items = [
41
40
  to: `https://claude.ai/new?q=${encodeURIComponent(`Read ${markdownLink.value} so I can ask questions about it.`)}`,
42
41
  },
43
42
  ]
43
+
44
+ async function copyPage() {
45
+ const page = await $fetch<string>(`/raw${route.path}.md`)
46
+ copy(page)
47
+ }
44
48
  </script>
45
49
 
46
50
  <template>
@@ -53,7 +57,7 @@ const items = [
53
57
  :ui="{
54
58
  leadingIcon: [copied ? 'text-primary' : 'text-neutral', 'size-3.5'],
55
59
  }"
56
- @click="copy(markdownLink)"
60
+ @click="copyPage"
57
61
  />
58
62
 
59
63
  <UDropdownMenu
@@ -2,7 +2,7 @@
2
2
  import { kebabCase } from 'scule'
3
3
  import type { ContentNavigationItem, Collections, DocsCollectionItem } from '@nuxt/content'
4
4
  import { findPageHeadline } from '@nuxt/content/utils'
5
- import { addPrerenderPath } from '~/utils/prerender'
5
+ import { addPrerenderPath } from '../../utils/prerender'
6
6
 
7
7
  definePageMeta({
8
8
  layout: 'docs',
@@ -0,0 +1,15 @@
1
+ export default defineI18nConfig(async () => {
2
+ const config = useRuntimeConfig().public
3
+
4
+ const messages: Record<string, Record<string, never>> = {}
5
+ await Promise.all(
6
+ config.i18n.locales.map(async (locale) => {
7
+ const localeFile = await import(`./locales/${locale.code}.json`)
8
+ messages[locale.code] = localeFile.default
9
+ }),
10
+ )
11
+
12
+ return {
13
+ messages,
14
+ }
15
+ })
@@ -0,0 +1,18 @@
1
+ {
2
+ "common": {
3
+ "or": "or"
4
+ },
5
+ "docs": {
6
+ "copy": {
7
+ "page": "Copy page",
8
+ "link": "Copy Markdown page",
9
+ "view": "View as Markdown",
10
+ "gpt": "Open in ChatGPT",
11
+ "claude": "Open in Claude"
12
+ },
13
+ "links": "Community",
14
+ "toc": "On this page",
15
+ "report": "Report an issue",
16
+ "edit": "Edit this page"
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "common": {
3
+ "or": "ou"
4
+ },
5
+ "docs": {
6
+ "copy": {
7
+ "page": "Copier la page",
8
+ "link": "Copier la page Markdown",
9
+ "view": "Voir en Markdown",
10
+ "gpt": "Ouvrir dans ChatGPT",
11
+ "claude": "Ouvrir dans Claude"
12
+ },
13
+ "links": "Communauté",
14
+ "toc": "Sur cette page",
15
+ "report": "Signaler un problème",
16
+ "edit": "Éditer cette page"
17
+ }
18
+ }
package/nuxt.config.ts CHANGED
@@ -4,6 +4,7 @@ const { resolve } = createResolver(import.meta.url)
4
4
 
5
5
  export default defineNuxtConfig({
6
6
  modules: [
7
+ resolve('./modules/default-configs'),
7
8
  '@nuxt/ui-pro',
8
9
  '@nuxt/content',
9
10
  '@nuxt/image',
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": "4.0.0-beta.9",
4
+ "version": "4.0.1",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
7
7
  "repository": {
@@ -12,6 +12,7 @@
12
12
  "license": "MIT",
13
13
  "files": [
14
14
  "app",
15
+ "i18n",
15
16
  "content.config.ts",
16
17
  "modules",
17
18
  "nuxt.config.ts",
@@ -27,14 +28,15 @@
27
28
  "@nuxt/content": "^3.6.3",
28
29
  "@nuxt/image": "^1.10.0",
29
30
  "@nuxt/kit": "^4.0.1",
30
- "@nuxt/ui-pro": "^3.2.0",
31
+ "@nuxt/ui-pro": "^3.3.0",
32
+ "@nuxtjs/i18n": "^10.0.3",
31
33
  "@nuxtjs/mdc": "^0.17.2",
32
34
  "@nuxtjs/robots": "^5.4.0",
33
35
  "@vueuse/core": "^13.5.0",
34
36
  "defu": "^6.1.4",
35
37
  "git-url-parse": "^16.1.0",
36
38
  "minimark": "^0.2.0",
37
- "motion-v": "^1.6.0",
39
+ "motion-v": "^1.6.1",
38
40
  "nuxt-llms": "^0.1.3",
39
41
  "nuxt-og-image": "^5.1.9",
40
42
  "pkg-types": "^2.2.0",
@@ -43,9 +45,6 @@
43
45
  "ufo": "^1.6.1",
44
46
  "unist-util-visit": "^5.0.0"
45
47
  },
46
- "devDependencies": {
47
- "@nuxtjs/i18n": "^9.5.6"
48
- },
49
48
  "peerDependencies": {
50
49
  "better-sqlite3": "12.x",
51
50
  "nuxt": "4.x"
@@ -1,6 +1,7 @@
1
1
  import { withLeadingSlash } from 'ufo'
2
2
  import { stringify } from 'minimark/stringify'
3
3
  import { queryCollection } from '@nuxt/content/nitro'
4
+ import type { Collections } from '@nuxt/content'
4
5
 
5
6
  export default eventHandler(async (event) => {
6
7
  const slug = getRouterParams(event)['slug.md']
@@ -9,7 +10,26 @@ export default eventHandler(async (event) => {
9
10
  }
10
11
 
11
12
  const path = withLeadingSlash(slug.replace('.md', ''))
12
- const page = await queryCollection(event, 'docs').path(path).first()
13
+ const config = useRuntimeConfig(event).public
14
+
15
+ let collectionName = 'docs'
16
+ if (config.i18n?.locales) {
17
+ const pathSegments = path.split('/').filter(Boolean)
18
+ const firstSegment = pathSegments[0]
19
+
20
+ const availableLocales = config.i18n.locales.map((locale: string | { code: string }) =>
21
+ typeof locale === 'string' ? locale : locale.code,
22
+ )
23
+
24
+ if (firstSegment && availableLocales.includes(firstSegment)) {
25
+ collectionName = `docs_${firstSegment}`
26
+ }
27
+ else if (config.i18n.defaultLocale) {
28
+ collectionName = `docs_${config.i18n.defaultLocale}`
29
+ }
30
+ }
31
+
32
+ const page = await queryCollection(event, collectionName as keyof Collections).path(path).first()
13
33
  if (!page) {
14
34
  throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
15
35
  }
package/utils/git.ts CHANGED
@@ -23,7 +23,7 @@ export function getGitBranch() {
23
23
  return envName
24
24
  }
25
25
  try {
26
- const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
26
+ const branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
27
27
  if (branch && branch !== 'HEAD') {
28
28
  return branch
29
29
  }