@levino/shipyard-docs 0.4.0 → 0.4.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/astro/DocsEntry.astro +19 -6
- package/package.json +4 -4
- package/src/index.ts +14 -5
package/astro/DocsEntry.astro
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
|
+
import config from 'virtual:shipyard/config'
|
|
3
4
|
import Layout from './Layout.astro'
|
|
4
5
|
|
|
5
6
|
export async function getStaticPaths() {
|
|
6
7
|
const docs = await getCollection('docs')
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
|
|
9
|
+
// Check if i18n is configured using Shipyard's config
|
|
10
|
+
const hasI18n = Boolean(config.i18n)
|
|
11
|
+
|
|
12
|
+
const getParams = (slug: string, hasI18n: boolean) => {
|
|
13
|
+
if (hasI18n) {
|
|
14
|
+
const [locale, ...rest] = slug.split('/')
|
|
15
|
+
return {
|
|
16
|
+
slug: rest.length ? rest.join('/') : undefined,
|
|
17
|
+
locale,
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
// For non-i18n, treat the entire slug as the path
|
|
21
|
+
return {
|
|
22
|
+
slug: slug || undefined,
|
|
23
|
+
}
|
|
12
24
|
}
|
|
13
25
|
}
|
|
26
|
+
|
|
14
27
|
return docs.map((entry) => ({
|
|
15
|
-
params: getParams(entry.id),
|
|
28
|
+
params: getParams(entry.id, hasI18n),
|
|
16
29
|
props: { entry },
|
|
17
30
|
}))
|
|
18
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levino/shipyard-docs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"astro": "^5"
|
|
11
|
+
"astro": "^5.7"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"effect": "^3.12.5",
|
|
15
15
|
"ramda": "^0.29.1",
|
|
16
|
-
"@levino/shipyard-base": "^0.5.
|
|
16
|
+
"@levino/shipyard-base": "^0.5.3"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@tailwindcss/typography": "^0.5.16",
|
|
20
20
|
"@types/ramda": "^0.29.9",
|
|
21
|
-
"astro": "^5",
|
|
21
|
+
"astro": "^5.7",
|
|
22
22
|
"vitest": "^2.1.8"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
package/src/index.ts
CHANGED
|
@@ -16,12 +16,21 @@ export const docsSchema = z.object({
|
|
|
16
16
|
export default (docsPaths: string[]): AstroIntegration => ({
|
|
17
17
|
name: 'shipyard-docs',
|
|
18
18
|
hooks: {
|
|
19
|
-
'astro:config:setup': ({ injectRoute }) => {
|
|
19
|
+
'astro:config:setup': ({ injectRoute, config }) => {
|
|
20
20
|
docsPaths.forEach((path) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
if (config.i18n) {
|
|
22
|
+
// With i18n: use locale prefix
|
|
23
|
+
injectRoute({
|
|
24
|
+
pattern: `/[locale]/${path}/[...slug]`,
|
|
25
|
+
entrypoint: `@levino/shipyard-docs/astro/DocsEntry.astro`,
|
|
26
|
+
})
|
|
27
|
+
} else {
|
|
28
|
+
// Without i18n: direct path
|
|
29
|
+
injectRoute({
|
|
30
|
+
pattern: `/${path}/[...slug]`,
|
|
31
|
+
entrypoint: `@levino/shipyard-docs/astro/DocsEntry.astro`,
|
|
32
|
+
})
|
|
33
|
+
}
|
|
25
34
|
})
|
|
26
35
|
},
|
|
27
36
|
},
|