create-specra 0.1.7 → 0.2.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/LICENSE.MD +16 -4
- package/README.md +53 -17
- package/dist/chunk-3DKWECRK.js +45 -0
- package/dist/chunk-3DKWECRK.js.map +1 -0
- package/dist/chunk-MA7QG54W.js +74 -0
- package/dist/chunk-MA7QG54W.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +33 -0
- package/dist/cli.js.map +1 -0
- package/dist/deploy-SCEMUQNS.js +141 -0
- package/dist/deploy-SCEMUQNS.js.map +1 -0
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/login-NKDRQXRE.js +71 -0
- package/dist/login-NKDRQXRE.js.map +1 -0
- package/dist/logout-H543QEKU.js +20 -0
- package/dist/logout-H543QEKU.js.map +1 -0
- package/dist/logs-YDAUCMAV.js +71 -0
- package/dist/logs-YDAUCMAV.js.map +1 -0
- package/dist/projects-3TAY7EDJ.js +42 -0
- package/dist/projects-3TAY7EDJ.js.map +1 -0
- package/package.json +9 -4
- package/templates/book-docs/docs/v1.0.0/concepts.mdx +89 -0
- package/templates/book-docs/docs/v1.0.0/content/_category_.json +7 -0
- package/templates/book-docs/docs/v1.0.0/content/formatting.mdx +128 -0
- package/templates/book-docs/docs/v1.0.0/content/reusable-content.mdx +116 -0
- package/templates/book-docs/docs/v1.0.0/content/structure.mdx +92 -0
- package/templates/book-docs/docs/v1.0.0/customization/_category_.json +7 -0
- package/templates/book-docs/docs/v1.0.0/customization/branding.mdx +115 -0
- package/templates/book-docs/docs/v1.0.0/customization/themes.mdx +81 -0
- package/templates/book-docs/docs/v1.0.0/introduction.mdx +38 -0
- package/templates/book-docs/docs/v1.0.0/quickstart.mdx +112 -0
- package/templates/book-docs/docs/v2.0.0/concepts.mdx +89 -0
- package/templates/book-docs/docs/v2.0.0/content/_category_.json +7 -0
- package/templates/book-docs/docs/v2.0.0/content/formatting.mdx +128 -0
- package/templates/book-docs/docs/v2.0.0/content/reusable-content.mdx +116 -0
- package/templates/book-docs/docs/v2.0.0/content/structure.mdx +92 -0
- package/templates/book-docs/docs/v2.0.0/customization/_category_.json +7 -0
- package/templates/book-docs/docs/v2.0.0/customization/branding.mdx +115 -0
- package/templates/book-docs/docs/v2.0.0/customization/themes.mdx +81 -0
- package/templates/book-docs/docs/v2.0.0/introduction.mdx +39 -0
- package/templates/book-docs/docs/v2.0.0/quickstart.mdx +112 -0
- package/templates/book-docs/gitignore +7 -0
- package/templates/book-docs/package.json +28 -0
- package/templates/book-docs/postcss.config.mjs +8 -0
- package/templates/book-docs/public/api-specs/openapi-example.json +259 -0
- package/templates/book-docs/public/api-specs/postman-example.json +205 -0
- package/templates/book-docs/public/api-specs/test-api.json +256 -0
- package/templates/book-docs/public/api-specs/users-api.json +264 -0
- package/templates/book-docs/specra.config.json +77 -0
- package/templates/{minimal/app/globals.css → book-docs/src/app.css} +3 -4
- package/templates/book-docs/src/app.html +17 -0
- package/templates/book-docs/src/routes/+layout.server.ts +11 -0
- package/templates/book-docs/src/routes/+layout.svelte +21 -0
- package/templates/book-docs/src/routes/+page.server.ts +9 -0
- package/templates/book-docs/src/routes/docs/[version]/[...slug]/+page.server.ts +119 -0
- package/templates/book-docs/src/routes/docs/[version]/[...slug]/+page.svelte +129 -0
- package/templates/book-docs/svelte.config.js +8 -0
- package/templates/book-docs/tsconfig.json +12 -0
- package/templates/book-docs/vite.config.ts +6 -0
- package/templates/jbrains-docs/docs/v1.0.0/advanced/_category_.json +8 -0
- package/templates/jbrains-docs/docs/v1.0.0/advanced/async.mdx +95 -0
- package/templates/jbrains-docs/docs/v1.0.0/advanced/generics.mdx +126 -0
- package/templates/jbrains-docs/docs/v1.0.0/basics/_category_.json +8 -0
- package/templates/jbrains-docs/docs/v1.0.0/basics/control-flow.mdx +106 -0
- package/templates/jbrains-docs/docs/v1.0.0/basics/syntax.mdx +129 -0
- package/templates/jbrains-docs/docs/v1.0.0/basics/types.mdx +135 -0
- package/templates/jbrains-docs/docs/v1.0.0/getting-started.mdx +111 -0
- package/templates/jbrains-docs/docs/v1.0.0/home.mdx +37 -0
- package/templates/jbrains-docs/docs/v1.0.0/tools/_category_.json +8 -0
- package/templates/jbrains-docs/docs/v1.0.0/tools/build-tools.mdx +165 -0
- package/templates/jbrains-docs/docs/v1.0.0/tools/testing.mdx +112 -0
- package/templates/jbrains-docs/docs/v2.0.0/advanced/_category_.json +8 -0
- package/templates/jbrains-docs/docs/v2.0.0/advanced/async.mdx +95 -0
- package/templates/jbrains-docs/docs/v2.0.0/advanced/generics.mdx +126 -0
- package/templates/jbrains-docs/docs/v2.0.0/basics/_category_.json +8 -0
- package/templates/jbrains-docs/docs/v2.0.0/basics/control-flow.mdx +106 -0
- package/templates/jbrains-docs/docs/v2.0.0/basics/syntax.mdx +129 -0
- package/templates/jbrains-docs/docs/v2.0.0/basics/types.mdx +135 -0
- package/templates/jbrains-docs/docs/v2.0.0/getting-started.mdx +111 -0
- package/templates/jbrains-docs/docs/v2.0.0/home.mdx +37 -0
- package/templates/jbrains-docs/docs/v2.0.0/tools/_category_.json +8 -0
- package/templates/jbrains-docs/docs/v2.0.0/tools/build-tools.mdx +165 -0
- package/templates/jbrains-docs/docs/v2.0.0/tools/testing.mdx +112 -0
- package/templates/jbrains-docs/gitignore +7 -0
- package/templates/jbrains-docs/package.json +28 -0
- package/templates/jbrains-docs/postcss.config.mjs +8 -0
- package/templates/jbrains-docs/public/api-specs/openapi-example.json +259 -0
- package/templates/jbrains-docs/public/api-specs/postman-example.json +205 -0
- package/templates/jbrains-docs/public/api-specs/test-api.json +256 -0
- package/templates/jbrains-docs/public/api-specs/users-api.json +264 -0
- package/templates/jbrains-docs/specra.config.json +80 -0
- package/templates/jbrains-docs/src/app.css +8 -0
- package/templates/jbrains-docs/src/app.html +17 -0
- package/templates/jbrains-docs/src/routes/+layout.server.ts +11 -0
- package/templates/jbrains-docs/src/routes/+layout.svelte +21 -0
- package/templates/jbrains-docs/src/routes/+page.server.ts +9 -0
- package/templates/jbrains-docs/src/routes/docs/[version]/[...slug]/+page.server.ts +119 -0
- package/templates/jbrains-docs/src/routes/docs/[version]/[...slug]/+page.svelte +129 -0
- package/templates/jbrains-docs/svelte.config.js +8 -0
- package/templates/jbrains-docs/tsconfig.json +12 -0
- package/templates/jbrains-docs/vite.config.ts +6 -0
- package/templates/minimal/docs/v1.0.0/about.mdx +3 -3
- package/templates/minimal/docs/v2.0.0/about.mdx +3 -3
- package/templates/minimal/gitignore +7 -0
- package/templates/minimal/package.json +18 -24
- package/templates/minimal/specra.config.json +12 -63
- package/templates/minimal/src/app.css +8 -0
- package/templates/minimal/src/app.html +17 -0
- package/templates/minimal/src/routes/+layout.server.ts +11 -0
- package/templates/minimal/src/routes/+layout.svelte +21 -0
- package/templates/minimal/src/routes/+page.server.ts +9 -0
- package/templates/minimal/src/routes/docs/[version]/[...slug]/+page.server.ts +119 -0
- package/templates/minimal/src/routes/docs/[version]/[...slug]/+page.svelte +129 -0
- package/templates/minimal/svelte.config.js +8 -0
- package/templates/minimal/tsconfig.json +7 -36
- package/templates/minimal/vite.config.ts +6 -0
- package/templates/minimal/README.md +0 -132
- package/templates/minimal/app/api/mdx-watch/route.ts +0 -6
- package/templates/minimal/app/api/search/route.ts +0 -75
- package/templates/minimal/app/docs/[version]/[...slug]/loading.tsx +0 -7
- package/templates/minimal/app/docs/[version]/[...slug]/page.tsx +0 -205
- package/templates/minimal/app/docs/[version]/[...slug]/page.tsx.bak +0 -203
- package/templates/minimal/app/docs/[version]/not-found.tsx +0 -10
- package/templates/minimal/app/docs/[version]/page.tsx +0 -27
- package/templates/minimal/app/layout.tsx +0 -62
- package/templates/minimal/app/not-found.tsx +0 -10
- package/templates/minimal/app/page.tsx +0 -179
- package/templates/minimal/next.config.mjs +0 -1
- package/templates/minimal/package-lock.json +0 -7881
- package/templates/minimal/proxy_.ts +0 -22
- package/templates/minimal/scripts/generate-redirects.mjs +0 -128
- package/templates/minimal/scripts/generate-static-redirects.mjs +0 -115
- package/templates/minimal/scripts/index-search.ts +0 -182
- package/templates/minimal/scripts/test-search.ts +0 -83
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
|
4
4
|
icon: info
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Specra is a self-hosted, Mintlify-quality documentation platform built with **
|
|
7
|
+
Specra is a self-hosted, Mintlify-quality documentation platform built with **SvelteKit**, **MDX**, and **Tailwind CSS**. It provides a polished, readable docs experience with powerful features for both readers and writers.
|
|
8
8
|
|
|
9
9
|
## Why Specra?
|
|
10
10
|
|
|
@@ -17,8 +17,8 @@ Specra is a self-hosted, Mintlify-quality documentation platform built with **Ne
|
|
|
17
17
|
|
|
18
18
|
## Built With
|
|
19
19
|
|
|
20
|
-
- **
|
|
21
|
-
- **MDX** - Markdown with
|
|
20
|
+
- **SvelteKit** - Svelte framework with file-based routing
|
|
21
|
+
- **MDX** - Markdown with Svelte components
|
|
22
22
|
- **Tailwind CSS** - Utility-first styling
|
|
23
23
|
- **Meilisearch** - Fast, typo-tolerant search
|
|
24
24
|
- **TypeScript** - Full type safety
|
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
|
4
4
|
icon: info
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Specra is a self-hosted, Mintlify-quality documentation platform built with **
|
|
7
|
+
Specra is a self-hosted, Mintlify-quality documentation platform built with **SvelteKit**, **MDX**, and **Tailwind CSS**. It provides a polished, readable docs experience with powerful features for both readers and writers.
|
|
8
8
|
|
|
9
9
|
## Why Specra?
|
|
10
10
|
|
|
@@ -17,8 +17,8 @@ Specra is a self-hosted, Mintlify-quality documentation platform built with **Ne
|
|
|
17
17
|
|
|
18
18
|
## Built With
|
|
19
19
|
|
|
20
|
-
- **
|
|
21
|
-
- **MDX** - Markdown with
|
|
20
|
+
- **SvelteKit** - Svelte framework with file-based routing
|
|
21
|
+
- **MDX** - Markdown with Svelte components
|
|
22
22
|
- **Tailwind CSS** - Utility-first styling
|
|
23
23
|
- **Meilisearch** - Fast, typo-tolerant search
|
|
24
24
|
- **TypeScript** - Full type safety
|
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
3
|
-
"version": "0.1
|
|
2
|
+
"name": "my-docs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"private": true,
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"dev": "
|
|
7
|
-
"build": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"lint": "eslint .",
|
|
11
|
-
"generate:redirects": "node scripts/generate-redirects.mjs",
|
|
12
|
-
"generate:static-redirects": "node scripts/generate-static-redirects.mjs",
|
|
13
|
-
"index:search": "tsx scripts/index-search.ts",
|
|
14
|
-
"test:search": "tsx scripts/test-search.ts"
|
|
7
|
+
"dev": "vite dev",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json"
|
|
15
11
|
},
|
|
16
12
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
-
"next": "^16.1.0",
|
|
19
|
-
"react": "^19.2.3",
|
|
20
|
-
"react-dom": "^19.2.3",
|
|
21
|
-
"specra": "^0.1.7"
|
|
13
|
+
"specra": "^0.2.1"
|
|
22
14
|
},
|
|
23
15
|
"devDependencies": {
|
|
24
|
-
"@
|
|
16
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
17
|
+
"@sveltejs/kit": "^2.0.0",
|
|
18
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
19
|
+
"@tailwindcss/postcss": "^4.1.9",
|
|
25
20
|
"@tailwindcss/typography": "^0.5.19",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"typescript": "^5"
|
|
21
|
+
"postcss": "^8.5",
|
|
22
|
+
"svelte": "^5.0.0",
|
|
23
|
+
"svelte-check": "^4.0.0",
|
|
24
|
+
"tailwindcss": "^4.1.9",
|
|
25
|
+
"typescript": "^5",
|
|
26
|
+
"vite": "^6.3.0"
|
|
33
27
|
}
|
|
34
28
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/specra/config/specra.config.schema.json",
|
|
3
3
|
"site": {
|
|
4
|
-
"title": "
|
|
5
|
-
"description": "
|
|
6
|
-
"url": "
|
|
4
|
+
"title": "My Docs",
|
|
5
|
+
"description": "Documentation for my project",
|
|
6
|
+
"url": "http://localhost:5173",
|
|
7
7
|
"baseUrl": "/",
|
|
8
8
|
"language": "en",
|
|
9
|
-
"organizationName": "
|
|
10
|
-
"projectName": "
|
|
11
|
-
"activeVersion": "v1.0.0"
|
|
12
|
-
"favicon": "/icon-light-32x32.png"
|
|
9
|
+
"organizationName": "my-org",
|
|
10
|
+
"projectName": "my-project",
|
|
11
|
+
"activeVersion": "v1.0.0"
|
|
13
12
|
},
|
|
14
13
|
"theme": {
|
|
15
14
|
"defaultMode": "system",
|
|
@@ -41,32 +40,13 @@
|
|
|
41
40
|
]
|
|
42
41
|
},
|
|
43
42
|
"social": {
|
|
44
|
-
"github": "https://github.com/
|
|
45
|
-
"twitter": "https://twitter.com/dalmasonto",
|
|
46
|
-
"discord": "https://discord.com/invite/dalmasonto",
|
|
47
|
-
"custom": [
|
|
48
|
-
{
|
|
49
|
-
"label": "Website",
|
|
50
|
-
"url": "https://craftfolio.com/dalmasonto"
|
|
51
|
-
}
|
|
52
|
-
]
|
|
43
|
+
"github": "https://github.com/your-org/your-repo"
|
|
53
44
|
},
|
|
54
45
|
"search": {
|
|
55
|
-
"enabled":
|
|
56
|
-
"placeholder": "Search documentation...",
|
|
57
|
-
"provider": "meilisearch",
|
|
58
|
-
"meilisearch": {
|
|
59
|
-
"host": "http://localhost:7700",
|
|
60
|
-
"apiKey": "aSampleMasterKey",
|
|
61
|
-
"indexName": "docs"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"analytics": {
|
|
65
|
-
"googleAnalytics": "",
|
|
66
|
-
"plausible": ""
|
|
46
|
+
"enabled": false
|
|
67
47
|
},
|
|
68
48
|
"footer": {
|
|
69
|
-
"copyright": "Copyright ©
|
|
49
|
+
"copyright": "Copyright © 2025 My Project. All rights reserved.",
|
|
70
50
|
"links": [
|
|
71
51
|
{
|
|
72
52
|
"title": "Documentation",
|
|
@@ -74,10 +54,6 @@
|
|
|
74
54
|
{
|
|
75
55
|
"label": "Getting Started",
|
|
76
56
|
"href": "/docs/v1.0.0/getting-started"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"label": "API Reference",
|
|
80
|
-
"href": "/docs/v1.0.0/api"
|
|
81
57
|
}
|
|
82
58
|
]
|
|
83
59
|
},
|
|
@@ -86,45 +62,18 @@
|
|
|
86
62
|
"items": [
|
|
87
63
|
{
|
|
88
64
|
"label": "GitHub",
|
|
89
|
-
"href": "https://github.com/
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"label": "Discord",
|
|
93
|
-
"href": "#"
|
|
65
|
+
"href": "https://github.com/your-org/your-repo"
|
|
94
66
|
}
|
|
95
67
|
]
|
|
96
68
|
}
|
|
97
|
-
]
|
|
98
|
-
"branding": {
|
|
99
|
-
"showBranding": true,
|
|
100
|
-
"logo": "https://tokenkit.s3.amazonaws.com/logo_fa8c1a32da814a209b06c742fbf2a862.png",
|
|
101
|
-
"title": "Specra",
|
|
102
|
-
"url": "https://specra.dev"
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
"banner": {
|
|
106
|
-
"enabled": false,
|
|
107
|
-
"message": "🎉 This is a development version. Some features may not work as expected.",
|
|
108
|
-
"type": "error",
|
|
109
|
-
"dismissible": true
|
|
69
|
+
]
|
|
110
70
|
},
|
|
111
71
|
"features": {
|
|
112
|
-
"editUrl": "https://github.com/yourusername/your-repo/edit/main/docs",
|
|
113
72
|
"showLastUpdated": true,
|
|
114
73
|
"showReadingTime": true,
|
|
115
74
|
"showAuthors": false,
|
|
116
75
|
"showTags": true,
|
|
117
76
|
"versioning": true,
|
|
118
77
|
"i18n": false
|
|
119
|
-
},
|
|
120
|
-
"env": {
|
|
121
|
-
"API_BASE_URL": "https://api.example.com",
|
|
122
|
-
"API_VERSION": "v1",
|
|
123
|
-
"CDN_URL": "https://cdn.example.com"
|
|
124
|
-
},
|
|
125
|
-
"deployment": {
|
|
126
|
-
"target": "vercel",
|
|
127
|
-
"basePath": "",
|
|
128
|
-
"customDomain": false
|
|
129
78
|
}
|
|
130
|
-
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%sveltekit.assets%/favicon.svg" type="image/svg+xml" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
|
+
<link
|
|
10
|
+
href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@100..900&family=Geist:wght@100..900&display=swap"
|
|
11
|
+
rel="stylesheet">
|
|
12
|
+
%sveltekit.head%
|
|
13
|
+
</head>
|
|
14
|
+
<body data-sveltekit-preload-data="hover" class="font-sans antialiased">
|
|
15
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getConfig, initConfig } from 'specra';
|
|
2
|
+
import specraConfig from '../../specra.config.json';
|
|
3
|
+
import type { LayoutServerLoad } from './$types';
|
|
4
|
+
import type { SpecraConfig } from 'specra';
|
|
5
|
+
|
|
6
|
+
initConfig(specraConfig as unknown as Partial<SpecraConfig>);
|
|
7
|
+
|
|
8
|
+
export const load: LayoutServerLoad = async () => {
|
|
9
|
+
const config = getConfig();
|
|
10
|
+
return { config };
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import '../app.css';
|
|
3
|
+
import { LayoutProviders } from 'specra/components';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type { LayoutData } from './$types';
|
|
6
|
+
|
|
7
|
+
let { data, children }: { data: LayoutData; children: Snippet } = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<svelte:head>
|
|
11
|
+
<title>{data?.config?.site?.title || 'Documentation'}</title>
|
|
12
|
+
<meta name="description" content={data?.config?.site?.description || 'Modern documentation platform'} />
|
|
13
|
+
</svelte:head>
|
|
14
|
+
|
|
15
|
+
{#if data?.config}
|
|
16
|
+
<LayoutProviders config={data.config}>
|
|
17
|
+
{@render children?.()}
|
|
18
|
+
</LayoutProviders>
|
|
19
|
+
{:else}
|
|
20
|
+
{@render children?.()}
|
|
21
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { redirect } from '@sveltejs/kit';
|
|
2
|
+
import { getConfig } from 'specra';
|
|
3
|
+
import type { PageServerLoad } from './$types';
|
|
4
|
+
|
|
5
|
+
export const load: PageServerLoad = async () => {
|
|
6
|
+
const config = getConfig();
|
|
7
|
+
const activeVersion = config.site?.activeVersion || 'v1.0.0';
|
|
8
|
+
redirect(302, `/docs/${activeVersion}/about`);
|
|
9
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractTableOfContents,
|
|
3
|
+
getAdjacentDocs,
|
|
4
|
+
isCategoryPage,
|
|
5
|
+
getCachedVersions,
|
|
6
|
+
getCachedAllDocs,
|
|
7
|
+
getCachedDocBySlug,
|
|
8
|
+
getI18nConfig,
|
|
9
|
+
getConfig,
|
|
10
|
+
} from 'specra';
|
|
11
|
+
import type { PageServerLoad } from './$types';
|
|
12
|
+
|
|
13
|
+
export const load: PageServerLoad = async ({ params }) => {
|
|
14
|
+
const { version, slug: slugArray } = params;
|
|
15
|
+
const slug = slugArray;
|
|
16
|
+
|
|
17
|
+
const i18nConfig = getI18nConfig();
|
|
18
|
+
const slugParts = slug.split('/');
|
|
19
|
+
let locale: string | undefined;
|
|
20
|
+
if (i18nConfig && i18nConfig.locales.includes(slugParts[0])) {
|
|
21
|
+
locale = slugParts[0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const allDocs = await getCachedAllDocs(version, locale);
|
|
25
|
+
const versions = getCachedVersions();
|
|
26
|
+
const config = getConfig();
|
|
27
|
+
const isCategory = isCategoryPage(slug, allDocs);
|
|
28
|
+
const doc = await getCachedDocBySlug(slug, version);
|
|
29
|
+
|
|
30
|
+
let title = 'Page Not Found';
|
|
31
|
+
let description = 'The requested documentation page could not be found.';
|
|
32
|
+
let ogUrl = `/docs/${version}/${slug}`;
|
|
33
|
+
|
|
34
|
+
if (doc) {
|
|
35
|
+
title = doc.meta.title || doc.title;
|
|
36
|
+
description = doc.meta.description || `Documentation for ${title}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Category page without doc content
|
|
40
|
+
if (!doc && isCategory) {
|
|
41
|
+
const categoryDoc = allDocs.find((d) => d.slug.startsWith(slug + '/'));
|
|
42
|
+
const categoryTabGroup = categoryDoc?.meta?.tab_group || categoryDoc?.categoryTabGroup;
|
|
43
|
+
const categoryTitle = slug
|
|
44
|
+
.split('/')
|
|
45
|
+
.pop()
|
|
46
|
+
?.replace(/-/g, ' ')
|
|
47
|
+
.replace(/\b\w/g, (l) => l.toUpperCase()) || 'Category';
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
version,
|
|
51
|
+
slug,
|
|
52
|
+
allDocs,
|
|
53
|
+
versions,
|
|
54
|
+
config,
|
|
55
|
+
isCategory: true,
|
|
56
|
+
isNotFound: false,
|
|
57
|
+
doc: null,
|
|
58
|
+
categoryTitle,
|
|
59
|
+
categoryDescription: 'Browse the documentation in this section.',
|
|
60
|
+
categoryTabGroup,
|
|
61
|
+
toc: [],
|
|
62
|
+
previous: null,
|
|
63
|
+
next: null,
|
|
64
|
+
title,
|
|
65
|
+
description,
|
|
66
|
+
ogUrl,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Not found
|
|
71
|
+
if (!doc) {
|
|
72
|
+
return {
|
|
73
|
+
version,
|
|
74
|
+
slug,
|
|
75
|
+
allDocs,
|
|
76
|
+
versions,
|
|
77
|
+
config,
|
|
78
|
+
isCategory: false,
|
|
79
|
+
isNotFound: true,
|
|
80
|
+
doc: null,
|
|
81
|
+
categoryTitle: null,
|
|
82
|
+
categoryDescription: null,
|
|
83
|
+
categoryTabGroup: undefined,
|
|
84
|
+
toc: [],
|
|
85
|
+
previous: null,
|
|
86
|
+
next: null,
|
|
87
|
+
title,
|
|
88
|
+
description,
|
|
89
|
+
ogUrl,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Normal doc page
|
|
94
|
+
const toc = extractTableOfContents(doc.meta.content || doc.content);
|
|
95
|
+
const { previous, next } = getAdjacentDocs(slug, allDocs);
|
|
96
|
+
const showCategoryIndex = isCategory && !!doc;
|
|
97
|
+
const matchingDoc = allDocs.find((d) => d.slug === slug);
|
|
98
|
+
const currentPageTabGroup = doc.meta?.tab_group || matchingDoc?.categoryTabGroup;
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
version,
|
|
102
|
+
slug,
|
|
103
|
+
allDocs,
|
|
104
|
+
versions,
|
|
105
|
+
config,
|
|
106
|
+
isCategory: showCategoryIndex,
|
|
107
|
+
isNotFound: false,
|
|
108
|
+
doc,
|
|
109
|
+
categoryTitle: null,
|
|
110
|
+
categoryDescription: null,
|
|
111
|
+
categoryTabGroup: currentPageTabGroup,
|
|
112
|
+
toc,
|
|
113
|
+
previous: previous ? { title: previous.meta.title, slug: previous.slug } : null,
|
|
114
|
+
next: next ? { title: next.meta.title, slug: next.slug } : null,
|
|
115
|
+
title,
|
|
116
|
+
description,
|
|
117
|
+
ogUrl,
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
TableOfContents,
|
|
4
|
+
Header,
|
|
5
|
+
DocLayout,
|
|
6
|
+
CategoryIndex,
|
|
7
|
+
HotReloadIndicator,
|
|
8
|
+
DevModeBadge,
|
|
9
|
+
MdxHotReload,
|
|
10
|
+
MdxContent,
|
|
11
|
+
NotFoundContent,
|
|
12
|
+
SearchHighlight,
|
|
13
|
+
MobileDocLayout,
|
|
14
|
+
mdxComponents,
|
|
15
|
+
} from 'specra/components';
|
|
16
|
+
import type { PageData } from './$types';
|
|
17
|
+
|
|
18
|
+
let { data }: { data: PageData } = $props();
|
|
19
|
+
|
|
20
|
+
let allDocsCompat: any[] = $derived(data.allDocs);
|
|
21
|
+
let previousDoc = $derived(data.previous ?? undefined);
|
|
22
|
+
let nextDoc = $derived(data.next ?? undefined);
|
|
23
|
+
let categoryTitle = $derived(data.categoryTitle ?? undefined);
|
|
24
|
+
let categoryDescription = $derived(data.categoryDescription ?? undefined);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<svelte:head>
|
|
28
|
+
<title>{data.title}</title>
|
|
29
|
+
<meta name="description" content={data.description} />
|
|
30
|
+
<meta property="og:title" content={data.title} />
|
|
31
|
+
<meta property="og:description" content={data.description} />
|
|
32
|
+
<meta property="og:url" content={data.ogUrl} />
|
|
33
|
+
<meta property="og:type" content="article" />
|
|
34
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
35
|
+
<meta name="twitter:title" content={data.title} />
|
|
36
|
+
<meta name="twitter:description" content={data.description} />
|
|
37
|
+
</svelte:head>
|
|
38
|
+
|
|
39
|
+
{#if !data.doc && data.isCategory}
|
|
40
|
+
<MobileDocLayout
|
|
41
|
+
docs={allDocsCompat}
|
|
42
|
+
version={data.version}
|
|
43
|
+
config={data.config}
|
|
44
|
+
activeTabGroup={data.categoryTabGroup}
|
|
45
|
+
>
|
|
46
|
+
{#snippet header()}
|
|
47
|
+
<Header currentVersion={data.version} versions={data.versions} config={data.config} />
|
|
48
|
+
{/snippet}
|
|
49
|
+
<CategoryIndex
|
|
50
|
+
categoryPath={data.slug}
|
|
51
|
+
version={data.version}
|
|
52
|
+
allDocs={allDocsCompat}
|
|
53
|
+
title={categoryTitle}
|
|
54
|
+
description={categoryDescription}
|
|
55
|
+
config={data.config}
|
|
56
|
+
/>
|
|
57
|
+
</MobileDocLayout>
|
|
58
|
+
<MdxHotReload />
|
|
59
|
+
<HotReloadIndicator />
|
|
60
|
+
<DevModeBadge />
|
|
61
|
+
{:else if data.isNotFound}
|
|
62
|
+
<MobileDocLayout
|
|
63
|
+
docs={allDocsCompat}
|
|
64
|
+
version={data.version}
|
|
65
|
+
config={data.config}
|
|
66
|
+
>
|
|
67
|
+
{#snippet header()}
|
|
68
|
+
<Header currentVersion={data.version} versions={data.versions} config={data.config} />
|
|
69
|
+
{/snippet}
|
|
70
|
+
<NotFoundContent version={data.version} />
|
|
71
|
+
</MobileDocLayout>
|
|
72
|
+
<MdxHotReload />
|
|
73
|
+
<HotReloadIndicator />
|
|
74
|
+
<DevModeBadge />
|
|
75
|
+
{:else if data.doc}
|
|
76
|
+
<MobileDocLayout
|
|
77
|
+
docs={allDocsCompat}
|
|
78
|
+
version={data.version}
|
|
79
|
+
config={data.config}
|
|
80
|
+
activeTabGroup={data.categoryTabGroup}
|
|
81
|
+
>
|
|
82
|
+
{#snippet header()}
|
|
83
|
+
<Header currentVersion={data.version} versions={data.versions} config={data.config} />
|
|
84
|
+
{/snippet}
|
|
85
|
+
{#snippet toc()}
|
|
86
|
+
{#if !data.isCategory}
|
|
87
|
+
<TableOfContents items={data.toc} config={data.config} />
|
|
88
|
+
{/if}
|
|
89
|
+
{/snippet}
|
|
90
|
+
|
|
91
|
+
{#if data.isCategory}
|
|
92
|
+
{#snippet categoryContent()}
|
|
93
|
+
{#if data.doc?.contentNodes}
|
|
94
|
+
<MdxContent nodes={data.doc.contentNodes} components={mdxComponents} />
|
|
95
|
+
{:else if data.doc?.content}
|
|
96
|
+
{@html data.doc.content}
|
|
97
|
+
{/if}
|
|
98
|
+
{/snippet}
|
|
99
|
+
<CategoryIndex
|
|
100
|
+
categoryPath={data.slug}
|
|
101
|
+
version={data.version}
|
|
102
|
+
allDocs={allDocsCompat}
|
|
103
|
+
title={data.doc.meta.title}
|
|
104
|
+
description={data.doc.meta.description}
|
|
105
|
+
content={categoryContent}
|
|
106
|
+
config={data.config}
|
|
107
|
+
/>
|
|
108
|
+
{:else}
|
|
109
|
+
<SearchHighlight />
|
|
110
|
+
<DocLayout
|
|
111
|
+
meta={data.doc.meta}
|
|
112
|
+
previousDoc={previousDoc}
|
|
113
|
+
nextDoc={nextDoc}
|
|
114
|
+
version={data.version}
|
|
115
|
+
slug={data.slug}
|
|
116
|
+
config={data.config}
|
|
117
|
+
>
|
|
118
|
+
{#if data.doc.contentNodes}
|
|
119
|
+
<MdxContent nodes={data.doc.contentNodes} components={mdxComponents} />
|
|
120
|
+
{:else}
|
|
121
|
+
{@html data.doc.content}
|
|
122
|
+
{/if}
|
|
123
|
+
</DocLayout>
|
|
124
|
+
{/if}
|
|
125
|
+
</MobileDocLayout>
|
|
126
|
+
<MdxHotReload />
|
|
127
|
+
<HotReloadIndicator />
|
|
128
|
+
<DevModeBadge />
|
|
129
|
+
{/if}
|
|
@@ -1,41 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "./.svelte-kit/tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"dom",
|
|
5
|
-
"dom.iterable",
|
|
6
|
-
"esnext"
|
|
7
|
-
],
|
|
8
4
|
"allowJs": true,
|
|
9
|
-
"
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"noEmit": true,
|
|
5
|
+
"checkJs": true,
|
|
13
6
|
"esModuleInterop": true,
|
|
14
|
-
"
|
|
15
|
-
"moduleResolution": "bundler",
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
8
|
"resolveJsonModule": true,
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
"name": "next"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"paths": {
|
|
26
|
-
"@/*": [
|
|
27
|
-
"./*"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"include": [
|
|
32
|
-
"next-env.d.ts",
|
|
33
|
-
"**/*.ts",
|
|
34
|
-
"**/*.tsx",
|
|
35
|
-
".next/types/**/*.ts",
|
|
36
|
-
".next/dev/types/**/*.ts"
|
|
37
|
-
],
|
|
38
|
-
"exclude": [
|
|
39
|
-
"node_modules"
|
|
40
|
-
]
|
|
41
|
-
}
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"strict": true
|
|
11
|
+
}
|
|
12
|
+
}
|