-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstackbit.config.ts
59 lines (57 loc) · 1.64 KB
/
stackbit.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// stackbit.config.ts
import path from "path";
import {
defineStackbitConfig,
SiteMapOptions,
SiteMapEntry,
Document,
} from "@stackbit/types";
import { GitContentSource, DocumentContext } from "@stackbit/cms-git";
import { page } from "./.stackbit/models/page";
const PAGES_DIR = "src/content/pages";
function filePathToPageUrl(filePath: string): string {
const pathObject = path.parse(filePath.substring(PAGES_DIR.length));
return (
(pathObject.name === "index"
? '/index'
: path.join(pathObject.dir, pathObject.name)) || "/index"
);
}
export default defineStackbitConfig({
stackbitVersion: "~0.6.0",
ssgName: "custom",
nodeVersion: "18",
postInstallCommand: `npm run build-custom-controls-config && npm run build-custom-controls`,
devCommand: "node_modules/.bin/astro dev --port {PORT} --hostname 127.0.0.1",
experimental: {
ssg: {
name: "Astro",
logPatterns: {
up: ["is ready", "astro"],
},
directRoutes: {
"socket.io": "socket.io",
},
passthrough: ["/vite-hmr/**"],
},
},
contentSources: [
new GitContentSource({
rootPath: __dirname,
contentDirs: ["src/content"],
models: [page],
}),
],
modelExtensions: [{ name: "page", type: "page", urlPath: "/{slug}" }],
sitemap: ({ documents }: SiteMapOptions): SiteMapEntry[] => {
return (documents as Document<DocumentContext>[]).map((document) => {
const filePath = document.context?.["filePath"] ?? document.id;
return {
stableId: document.id,
label: filePath,
urlPath: filePathToPageUrl(filePath),
document: document,
};
});
},
});