svedocs-cli 0.1.0-beta.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 +5 -0
- package/README.md +26 -0
- package/dist/chunk-QD6TB2KV.js +751 -0
- package/dist/create-svedocs.d.ts +1 -0
- package/dist/create-svedocs.js +12 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +12 -0
- package/dist/svedocs.d.ts +1 -0
- package/dist/svedocs.js +12 -0
- package/package.json +48 -0
- package/templates/cloudflare/.dev.vars.example +14 -0
- package/templates/cloudflare/README.md +13 -0
- package/templates/cloudflare/content/docs/index.md +20 -0
- package/templates/cloudflare/content/pages/index.md +9 -0
- package/templates/cloudflare/package.json +35 -0
- package/templates/cloudflare/src/app.cloudflare.d.ts +21 -0
- package/templates/cloudflare/src/app.d.ts +35 -0
- package/templates/cloudflare/src/app.html +12 -0
- package/templates/cloudflare/src/lib/server/env.ts +3 -0
- package/templates/cloudflare/src/routes/+layout.svelte +5 -0
- package/templates/cloudflare/src/routes/+layout.ts +3 -0
- package/templates/cloudflare/src/routes/+page.svelte +8 -0
- package/templates/cloudflare/src/routes/+page.ts +12 -0
- package/templates/cloudflare/src/routes/[...path]/+page.svelte +8 -0
- package/templates/cloudflare/src/routes/[...path]/+page.ts +22 -0
- package/templates/cloudflare/src/routes/api/ask/+server.ts +15 -0
- package/templates/cloudflare/src/routes/api/search/+server.ts +13 -0
- package/templates/cloudflare/src/routes/og/[...path]/+server.ts +26 -0
- package/templates/cloudflare/src/routes/robots.txt/+server.ts +12 -0
- package/templates/cloudflare/src/routes/sitemap.xml/+server.ts +13 -0
- package/templates/cloudflare/static/favicon.svg +6 -0
- package/templates/cloudflare/svedocs.config.ts +26 -0
- package/templates/cloudflare/svelte.config.js +18 -0
- package/templates/cloudflare/tsconfig.json +7 -0
- package/templates/cloudflare/vite.config.ts +9 -0
- package/templates/cloudflare/wrangler.toml +7 -0
- package/templates/docs/README.md +12 -0
- package/templates/docs/content/docs/index.md +14 -0
- package/templates/docs/content/pages/index.md +9 -0
- package/templates/docs/package.json +32 -0
- package/templates/docs/src/app.d.ts +35 -0
- package/templates/docs/src/app.html +12 -0
- package/templates/docs/src/lib/server/env.ts +3 -0
- package/templates/docs/src/routes/+layout.svelte +5 -0
- package/templates/docs/src/routes/+layout.ts +3 -0
- package/templates/docs/src/routes/+page.svelte +8 -0
- package/templates/docs/src/routes/+page.ts +12 -0
- package/templates/docs/src/routes/[...path]/+page.svelte +8 -0
- package/templates/docs/src/routes/[...path]/+page.ts +22 -0
- package/templates/docs/src/routes/api/ask/+server.ts +16 -0
- package/templates/docs/src/routes/api/search/+server.ts +13 -0
- package/templates/docs/src/routes/og/[...path]/+server.ts +26 -0
- package/templates/docs/src/routes/robots.txt/+server.ts +12 -0
- package/templates/docs/src/routes/sitemap.xml/+server.ts +13 -0
- package/templates/docs/static/favicon.svg +6 -0
- package/templates/docs/svedocs.config.ts +12 -0
- package/templates/docs/svelte.config.js +18 -0
- package/templates/docs/tsconfig.json +7 -0
- package/templates/docs/vite.config.ts +9 -0
- package/templates/minimal/README.md +12 -0
- package/templates/minimal/content/docs/index.md +8 -0
- package/templates/minimal/content/pages/index.md +9 -0
- package/templates/minimal/package.json +32 -0
- package/templates/minimal/src/app.d.ts +35 -0
- package/templates/minimal/src/app.html +12 -0
- package/templates/minimal/src/routes/+layout.svelte +5 -0
- package/templates/minimal/src/routes/+layout.ts +3 -0
- package/templates/minimal/src/routes/+page.svelte +8 -0
- package/templates/minimal/src/routes/+page.ts +12 -0
- package/templates/minimal/src/routes/[...path]/+page.svelte +8 -0
- package/templates/minimal/src/routes/[...path]/+page.ts +22 -0
- package/templates/minimal/static/favicon.svg +6 -0
- package/templates/minimal/svedocs.config.ts +10 -0
- package/templates/minimal/svelte.config.js +18 -0
- package/templates/minimal/tsconfig.json +7 -0
- package/templates/minimal/vite.config.ts +9 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runCreateSvedocsCli
|
|
4
|
+
} from "./chunk-QD6TB2KV.js";
|
|
5
|
+
|
|
6
|
+
// src/create-svedocs.ts
|
|
7
|
+
var result = await runCreateSvedocsCli(process.argv.slice(2));
|
|
8
|
+
var output = result.ok ? console.log : console.error;
|
|
9
|
+
output(result.message);
|
|
10
|
+
if (!result.ok) {
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface CliResult {
|
|
2
|
+
command: string;
|
|
3
|
+
args: string[];
|
|
4
|
+
ok: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type PackageManagerName = 'pnpm' | 'npm' | 'yarn' | 'bun';
|
|
9
|
+
|
|
10
|
+
interface CreateSvedocsRuntime {
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
readPackageManagerVersion?: (name: PackageManagerName) => Promise<string | undefined>;
|
|
13
|
+
}
|
|
14
|
+
declare function renderCreateSvedocsHelp(): string;
|
|
15
|
+
declare function runCreateSvedocsCli(args: string[], runtime?: CreateSvedocsRuntime): Promise<CliResult>;
|
|
16
|
+
|
|
17
|
+
declare function renderSvedocsHelp(): string;
|
|
18
|
+
declare function runSvedocsCli(args: string[]): Promise<CliResult>;
|
|
19
|
+
|
|
20
|
+
export { type CliResult, type CreateSvedocsRuntime, renderCreateSvedocsHelp, renderSvedocsHelp, runCreateSvedocsCli, runSvedocsCli };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/svedocs.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runSvedocsCli
|
|
4
|
+
} from "./chunk-QD6TB2KV.js";
|
|
5
|
+
|
|
6
|
+
// src/svedocs.ts
|
|
7
|
+
var result = await runSvedocsCli(process.argv.slice(2));
|
|
8
|
+
var output = result.ok ? console.log : console.error;
|
|
9
|
+
output(result.message);
|
|
10
|
+
if (!result.ok) {
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svedocs-cli",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "CLI for the svedocs documentation framework.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/backrunner/svedocs.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/backrunner/svedocs/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/backrunner/svedocs/tree/main/packages/cli#readme",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"provenance": true
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"svedocs": "./dist/svedocs.js",
|
|
22
|
+
"create-svedocs": "./dist/create-svedocs.js"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"templates",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"commander": "14.0.3",
|
|
38
|
+
"svedocs": "0.1.0-beta.1"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup src/index.ts src/svedocs.ts src/create-svedocs.ts --format esm --dts --clean",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
44
|
+
"lint": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"pack:dry-run": "pnpm pack --dry-run",
|
|
46
|
+
"dev": "tsup src/index.ts src/svedocs.ts src/create-svedocs.ts --format esm --dts --watch"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
SVEDOCS_AI_SEARCH_INSTANCE=svedocs
|
|
2
|
+
|
|
3
|
+
# Optional hosted search providers. Keep real keys in .dev.vars or platform secrets.
|
|
4
|
+
ALGOLIA_APP_ID=
|
|
5
|
+
ALGOLIA_SEARCH_KEY=
|
|
6
|
+
ALGOLIA_INDEX_NAME=docs
|
|
7
|
+
TYPESENSE_HOST=
|
|
8
|
+
TYPESENSE_SEARCH_KEY=
|
|
9
|
+
TYPESENSE_COLLECTION=docs
|
|
10
|
+
|
|
11
|
+
# Optional OpenAI-compatible Ask AI provider.
|
|
12
|
+
OPENAI_COMPATIBLE_API_KEY=
|
|
13
|
+
OPENAI_COMPATIBLE_BASE_URL=https://api.openai.com/v1
|
|
14
|
+
OPENAI_COMPATIBLE_MODEL=gpt-4.1-mini
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# svedocs Cloudflare
|
|
2
|
+
|
|
3
|
+
Cloudflare-first svedocs starter.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm install
|
|
7
|
+
pnpm dev
|
|
8
|
+
pnpm build
|
|
9
|
+
pnpm build:ssg
|
|
10
|
+
pnpm preview:cloudflare
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The default build uses `@sveltejs/adapter-cloudflare` with local remote bindings disabled, so builds do not require a Cloudflare account. Static SSG builds are available with `pnpm build:ssg` or `svedocs build --mode static`; `pnpm build:spa` adds a static fallback for hosts that need one.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: Build and deploy svedocs on Cloudflare.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Introduction
|
|
7
|
+
|
|
8
|
+
This project uses the Cloudflare adapter by default.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pnpm build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Preview
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm preview:cloudflare
|
|
20
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svedocs-cloudflare",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "svedocs dev",
|
|
8
|
+
"build": "svedocs build",
|
|
9
|
+
"build:edge": "svedocs build --mode edge",
|
|
10
|
+
"build:static": "svedocs build --mode static",
|
|
11
|
+
"build:ssg": "svedocs ssg",
|
|
12
|
+
"build:spa": "svedocs build --mode spa",
|
|
13
|
+
"preview": "svedocs preview",
|
|
14
|
+
"preview:cloudflare": "wrangler pages dev .svelte-kit/cloudflare",
|
|
15
|
+
"deploy": "wrangler pages deploy .svelte-kit/cloudflare",
|
|
16
|
+
"check": "svelte-kit sync && tsc -p tsconfig.json --noEmit"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@sveltejs/adapter-cloudflare": "^7.2.8",
|
|
20
|
+
"@sveltejs/adapter-static": "^3.0.10",
|
|
21
|
+
"@sveltejs/kit": "^2.60.1",
|
|
22
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
23
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
24
|
+
"svelte": "^5.55.7",
|
|
25
|
+
"svedocs": "latest",
|
|
26
|
+
"tailwindcss": "^4.3.0",
|
|
27
|
+
"vite": "^8.0.13",
|
|
28
|
+
"wrangler": "^4.92.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"svedocs-cli": "latest",
|
|
32
|
+
"@types/node": "^25.8.0",
|
|
33
|
+
"typescript": "^6.0.3"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare namespace App {
|
|
2
|
+
interface Platform {
|
|
3
|
+
env: {
|
|
4
|
+
SVEDOCS_AI_SEARCH?: import('svedocs/search').CloudflareAiSearchInstance;
|
|
5
|
+
AI?: import('svedocs/ai').CloudflareWorkersAiBinding;
|
|
6
|
+
ALGOLIA_APP_ID?: string;
|
|
7
|
+
ALGOLIA_SEARCH_KEY?: string;
|
|
8
|
+
ALGOLIA_INDEX_NAME?: string;
|
|
9
|
+
TYPESENSE_HOST?: string;
|
|
10
|
+
TYPESENSE_SEARCH_KEY?: string;
|
|
11
|
+
TYPESENSE_COLLECTION?: string;
|
|
12
|
+
OPENAI_COMPATIBLE_API_KEY?: string;
|
|
13
|
+
OPENAI_COMPATIBLE_BASE_URL?: string;
|
|
14
|
+
OPENAI_COMPATIBLE_MODEL?: string;
|
|
15
|
+
};
|
|
16
|
+
context: {
|
|
17
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
18
|
+
};
|
|
19
|
+
caches: CacheStorage;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare module 'virtual:svedocs/config' {
|
|
2
|
+
import type { SvedocsResolvedConfig } from 'svedocs/core';
|
|
3
|
+
const config: SvedocsResolvedConfig;
|
|
4
|
+
export default config;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module 'virtual:svedocs/pages' {
|
|
8
|
+
import type { SvedocsPage } from 'svedocs/core';
|
|
9
|
+
const pages: SvedocsPage[];
|
|
10
|
+
export default pages;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module 'virtual:svedocs/tree' {
|
|
14
|
+
import type { SvedocsTreeItem } from 'svedocs/core';
|
|
15
|
+
const tree: SvedocsTreeItem[];
|
|
16
|
+
export default tree;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module 'virtual:svedocs/search' {
|
|
20
|
+
import type { SvedocsSearchRecord } from 'svedocs/core';
|
|
21
|
+
const records: SvedocsSearchRecord[];
|
|
22
|
+
export default records;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module 'virtual:svedocs/components' {
|
|
26
|
+
import type { Component } from 'svelte';
|
|
27
|
+
const components: Record<string, Component>;
|
|
28
|
+
export default components;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module 'virtual:svedocs/layouts' {
|
|
32
|
+
import type { Component } from 'svelte';
|
|
33
|
+
const layouts: Record<string, Component>;
|
|
34
|
+
export default layouts;
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<link rel="icon" href="/favicon.svg" />
|
|
7
|
+
%sveltekit.head%
|
|
8
|
+
</head>
|
|
9
|
+
<body data-sveltekit-preload-data="hover">
|
|
10
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DocsApp } from 'svedocs/theme';
|
|
3
|
+
import components from 'virtual:svedocs/components';
|
|
4
|
+
import layouts from 'virtual:svedocs/layouts';
|
|
5
|
+
export let data;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<DocsApp page={data.page} pages={data.pages} tree={data.tree} search={data.search} config={data.config} {components} {layouts} />
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import config from 'virtual:svedocs/config';
|
|
2
|
+
import pages from 'virtual:svedocs/pages';
|
|
3
|
+
import search from 'virtual:svedocs/search';
|
|
4
|
+
import tree from 'virtual:svedocs/tree';
|
|
5
|
+
import { svedocsPagePrerender } from 'svedocs/cloudflare';
|
|
6
|
+
import type { PageLoad } from './$types';
|
|
7
|
+
|
|
8
|
+
export const prerender = svedocsPagePrerender();
|
|
9
|
+
|
|
10
|
+
export const load: PageLoad = () => {
|
|
11
|
+
return { page: pages.find((page) => page.routePath === '/'), pages, search, tree, config };
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DocsApp } from 'svedocs/theme';
|
|
3
|
+
import components from 'virtual:svedocs/components';
|
|
4
|
+
import layouts from 'virtual:svedocs/layouts';
|
|
5
|
+
export let data;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<DocsApp page={data.page} pages={data.pages} tree={data.tree} search={data.search} config={data.config} {components} {layouts} />
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { error } from '@sveltejs/kit';
|
|
2
|
+
import config from 'virtual:svedocs/config';
|
|
3
|
+
import pages from 'virtual:svedocs/pages';
|
|
4
|
+
import search from 'virtual:svedocs/search';
|
|
5
|
+
import tree from 'virtual:svedocs/tree';
|
|
6
|
+
import { svedocsPagePrerender } from 'svedocs/cloudflare';
|
|
7
|
+
import type { PageLoad } from './$types';
|
|
8
|
+
|
|
9
|
+
export const prerender = svedocsPagePrerender();
|
|
10
|
+
|
|
11
|
+
export function entries() {
|
|
12
|
+
return pages
|
|
13
|
+
.filter((page) => page.routePath !== '/')
|
|
14
|
+
.map((page) => ({ path: page.routePath.replace(/^\//, '') }));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const load: PageLoad = ({ params }) => {
|
|
18
|
+
const routePath = `/${params.path ?? ''}`.replace(/\/$/, '') || '/';
|
|
19
|
+
const page = pages.find((item) => item.routePath === routePath);
|
|
20
|
+
if (!page) error(404, `No page found for ${routePath}`);
|
|
21
|
+
return { page, pages, search, tree, config };
|
|
22
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createConfiguredAskResponse, createMemoryRateLimiter } from 'svedocs/ai';
|
|
2
|
+
import { getRuntimeEnv } from '$lib/server/env';
|
|
3
|
+
import config from 'virtual:svedocs/config';
|
|
4
|
+
import records from 'virtual:svedocs/search';
|
|
5
|
+
import type { RequestHandler } from './$types';
|
|
6
|
+
|
|
7
|
+
export const prerender = false;
|
|
8
|
+
const rateLimiter = createMemoryRateLimiter({ windowMs: 60_000, max: 30 });
|
|
9
|
+
|
|
10
|
+
export const POST: RequestHandler = ({ platform, request }) => {
|
|
11
|
+
return createConfiguredAskResponse(config, records, request, {
|
|
12
|
+
env: getRuntimeEnv(platform?.env),
|
|
13
|
+
rateLimiter
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createConfiguredSearchResponse } from 'svedocs/search';
|
|
2
|
+
import { getRuntimeEnv } from '$lib/server/env';
|
|
3
|
+
import config from 'virtual:svedocs/config';
|
|
4
|
+
import records from 'virtual:svedocs/search';
|
|
5
|
+
import type { RequestHandler } from './$types';
|
|
6
|
+
|
|
7
|
+
export const prerender = false;
|
|
8
|
+
|
|
9
|
+
export const GET: RequestHandler = ({ platform, request }) => {
|
|
10
|
+
return createConfiguredSearchResponse(config, records, request, {
|
|
11
|
+
env: getRuntimeEnv(platform?.env)
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { error } from '@sveltejs/kit';
|
|
2
|
+
import { createConfiguredOgImageFormat, createConfiguredOgImageRenderer, createPageOgImageEntries, createPageOgImagePath, createPageOgImageResponse } from 'svedocs/og';
|
|
3
|
+
import config from 'virtual:svedocs/config';
|
|
4
|
+
import pages from 'virtual:svedocs/pages';
|
|
5
|
+
import type { RequestHandler } from './$types';
|
|
6
|
+
|
|
7
|
+
export const prerender = true;
|
|
8
|
+
|
|
9
|
+
const format = createConfiguredOgImageFormat(config);
|
|
10
|
+
|
|
11
|
+
export function entries() {
|
|
12
|
+
return createPageOgImageEntries(pages, format);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const GET: RequestHandler = async ({ params }) => {
|
|
16
|
+
const requestPath = `/og/${params.path}`;
|
|
17
|
+
const page = pages.find((candidate) => createPageOgImagePath(candidate, format) === requestPath);
|
|
18
|
+
if (!page) error(404, `No OG image found for ${requestPath}`);
|
|
19
|
+
return createPageOgImageResponse(config, page, {
|
|
20
|
+
format,
|
|
21
|
+
renderer: createConfiguredOgImageRenderer(config),
|
|
22
|
+
...(config.seo.ogImage !== false && typeof config.seo.ogImage.template === 'function'
|
|
23
|
+
? { template: config.seo.ogImage.template }
|
|
24
|
+
: {})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRobotsTxt } from 'svedocs/og';
|
|
2
|
+
import config from 'virtual:svedocs/config';
|
|
3
|
+
|
|
4
|
+
export const prerender = true;
|
|
5
|
+
|
|
6
|
+
export function GET() {
|
|
7
|
+
return new Response(createRobotsTxt(config), {
|
|
8
|
+
headers: {
|
|
9
|
+
'content-type': 'text/plain; charset=utf-8'
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createSitemapXml } from 'svedocs/og';
|
|
2
|
+
import config from 'virtual:svedocs/config';
|
|
3
|
+
import pages from 'virtual:svedocs/pages';
|
|
4
|
+
|
|
5
|
+
export const prerender = true;
|
|
6
|
+
|
|
7
|
+
export function GET() {
|
|
8
|
+
return new Response(createSitemapXml(config, pages), {
|
|
9
|
+
headers: {
|
|
10
|
+
'content-type': 'application/xml; charset=utf-8'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
|
|
2
|
+
<rect width="64" height="64" fill="#11130f"/>
|
|
3
|
+
<rect x="12" y="12" width="16" height="16" fill="#50d6b3"/>
|
|
4
|
+
<rect x="28" y="28" width="16" height="16" fill="#ff8a66"/>
|
|
5
|
+
<rect x="12" y="44" width="16" height="8" fill="#f4f1e8"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from 'svedocs/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
site: {
|
|
5
|
+
name: 'svedocs cloudflare',
|
|
6
|
+
title: 'svedocs cloudflare',
|
|
7
|
+
description: 'Edge-first documentation powered by svedocs and Cloudflare Pages.'
|
|
8
|
+
},
|
|
9
|
+
search: {
|
|
10
|
+
enabled: true,
|
|
11
|
+
provider: 'cloudflare-ai-search'
|
|
12
|
+
},
|
|
13
|
+
ai: {
|
|
14
|
+
enabled: true,
|
|
15
|
+
provider: 'cloudflare-ai-search'
|
|
16
|
+
},
|
|
17
|
+
source: {
|
|
18
|
+
editBaseUrl: 'https://github.com/acme/my-docs/edit/main'
|
|
19
|
+
},
|
|
20
|
+
cloudflare: {
|
|
21
|
+
aiSearch: {
|
|
22
|
+
binding: 'SVEDOCS_AI_SEARCH',
|
|
23
|
+
instanceName: 'svedocs'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import adapterCloudflare from '@sveltejs/adapter-cloudflare';
|
|
2
|
+
import adapterStatic from '@sveltejs/adapter-static';
|
|
3
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
4
|
+
import { svedocsPreprocess, svedocsSvelteExtensions } from 'svedocs/svelte';
|
|
5
|
+
|
|
6
|
+
const mode = process.env.SVEDOCS_BUILD_MODE ?? 'edge';
|
|
7
|
+
const adapter =
|
|
8
|
+
mode === 'edge'
|
|
9
|
+
? adapterCloudflare({ platformProxy: { remoteBindings: false } })
|
|
10
|
+
: adapterStatic(mode === 'spa' ? { fallback: '200.html' } : { strict: false });
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
extensions: svedocsSvelteExtensions,
|
|
14
|
+
preprocess: [vitePreprocess(), svedocsPreprocess()],
|
|
15
|
+
kit: {
|
|
16
|
+
adapter
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
2
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import { svedocs } from 'svedocs/vite';
|
|
5
|
+
import svedocsConfig from './svedocs.config';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [svedocs({ config: svedocsConfig }), tailwindcss(), sveltekit()]
|
|
9
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# svedocs docs
|
|
2
|
+
|
|
3
|
+
Documentation starter powered by svedocs.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm install
|
|
7
|
+
pnpm dev
|
|
8
|
+
pnpm build
|
|
9
|
+
pnpm build:ssg
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`pnpm build` targets Cloudflare edge SSR by default with local remote bindings disabled, so builds do not require a Cloudflare account. Use `pnpm build:ssg` for static output or `pnpm build:spa` for prerendered pages plus a static fallback.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: Your first svedocs page.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Introduction
|
|
7
|
+
|
|
8
|
+
Welcome to svedocs.
|
|
9
|
+
|
|
10
|
+
## Next steps
|
|
11
|
+
|
|
12
|
+
- Configure `svedocs.config.ts`.
|
|
13
|
+
- Add pages under `content/docs`.
|
|
14
|
+
- Deploy to Cloudflare or build statically.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "svedocs-app",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "svedocs dev",
|
|
8
|
+
"build": "svedocs build",
|
|
9
|
+
"build:edge": "svedocs build --mode edge",
|
|
10
|
+
"build:static": "svedocs build --mode static",
|
|
11
|
+
"build:ssg": "svedocs ssg",
|
|
12
|
+
"build:spa": "svedocs build --mode spa",
|
|
13
|
+
"preview": "svedocs preview",
|
|
14
|
+
"check": "svedocs check"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@sveltejs/adapter-cloudflare": "^7.2.8",
|
|
18
|
+
"@sveltejs/adapter-static": "^3.0.10",
|
|
19
|
+
"@sveltejs/kit": "^2.60.1",
|
|
20
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
21
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
22
|
+
"svelte": "^5.55.7",
|
|
23
|
+
"svedocs": "latest",
|
|
24
|
+
"tailwindcss": "^4.3.0",
|
|
25
|
+
"vite": "^8.0.13"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"svedocs-cli": "latest",
|
|
29
|
+
"@types/node": "^25.8.0",
|
|
30
|
+
"typescript": "^6.0.3"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare module 'virtual:svedocs/config' {
|
|
2
|
+
import type { SvedocsResolvedConfig } from 'svedocs/core';
|
|
3
|
+
const config: SvedocsResolvedConfig;
|
|
4
|
+
export default config;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module 'virtual:svedocs/pages' {
|
|
8
|
+
import type { SvedocsPage } from 'svedocs/core';
|
|
9
|
+
const pages: SvedocsPage[];
|
|
10
|
+
export default pages;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module 'virtual:svedocs/tree' {
|
|
14
|
+
import type { SvedocsTreeItem } from 'svedocs/core';
|
|
15
|
+
const tree: SvedocsTreeItem[];
|
|
16
|
+
export default tree;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module 'virtual:svedocs/search' {
|
|
20
|
+
import type { SvedocsSearchRecord } from 'svedocs/core';
|
|
21
|
+
const records: SvedocsSearchRecord[];
|
|
22
|
+
export default records;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module 'virtual:svedocs/components' {
|
|
26
|
+
import type { Component } from 'svelte';
|
|
27
|
+
const components: Record<string, Component>;
|
|
28
|
+
export default components;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module 'virtual:svedocs/layouts' {
|
|
32
|
+
import type { Component } from 'svelte';
|
|
33
|
+
const layouts: Record<string, Component>;
|
|
34
|
+
export default layouts;
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<link rel="icon" href="/favicon.svg" />
|
|
7
|
+
%sveltekit.head%
|
|
8
|
+
</head>
|
|
9
|
+
<body data-sveltekit-preload-data="hover">
|
|
10
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|