@stackbox/cms 0.0.5 → 0.1.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 +158 -10
- package/dist/AGENTS.md +218 -0
- package/dist/blocks.d.ts +6 -13
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +2 -0
- package/dist/blocks.js.map +1 -1
- package/dist/build.d.ts +14 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +145 -0
- package/dist/build.js.map +1 -0
- package/dist/cache.d.ts +14 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +93 -0
- package/dist/cache.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/link.d.ts +3 -7
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +12 -19
- package/dist/link.js.map +1 -1
- package/dist/merge-hooks.d.ts +3 -0
- package/dist/merge-hooks.d.ts.map +1 -0
- package/dist/merge-hooks.js +54 -0
- package/dist/merge-hooks.js.map +1 -0
- package/dist/pages.d.ts +15 -46
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +2 -0
- package/dist/pages.js.map +1 -1
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +156 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/blog/index.d.ts +6 -5
- package/dist/plugins/blog/index.d.ts.map +1 -1
- package/dist/plugins/blog/index.js +16 -0
- package/dist/plugins/blog/index.js.map +1 -1
- package/dist/plugins/random-quote/assets/quotes.json +230 -0
- package/dist/plugins/random-quote/index.d.ts +3 -1
- package/dist/plugins/random-quote/index.d.ts.map +1 -1
- package/dist/plugins/random-quote/index.js +15 -1
- package/dist/plugins/random-quote/index.js.map +1 -1
- package/dist/plugins/sitemap/index.d.ts +14 -0
- package/dist/plugins/sitemap/index.d.ts.map +1 -0
- package/dist/plugins/sitemap/index.js +119 -0
- package/dist/plugins/sitemap/index.js.map +1 -0
- package/dist/render-head.d.ts +2 -2
- package/dist/render-head.d.ts.map +1 -1
- package/dist/render-page.d.ts +2 -4
- package/dist/render-page.d.ts.map +1 -1
- package/dist/render-page.js +7 -3
- package/dist/render-page.js.map +1 -1
- package/dist/site.d.ts +10 -17
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +155 -7
- package/dist/site.js.map +1 -1
- package/dist/slot-content.d.ts +3 -19
- package/dist/slot-content.d.ts.map +1 -1
- package/dist/slot-content.js.map +1 -1
- package/dist/slot-handle.d.ts +7 -25
- package/dist/slot-handle.d.ts.map +1 -1
- package/dist/slot-handle.js +29 -14
- package/dist/slot-handle.js.map +1 -1
- package/dist/stackbox/context.d.ts +2 -51
- package/dist/stackbox/context.d.ts.map +1 -1
- package/dist/stackbox/context.js.map +1 -1
- package/dist/templates.d.ts +7 -57
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js.map +1 -1
- package/dist/types.d.ts +281 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +17 -6
- package/src/plugins/blog/AGENTS.md +5 -1
- package/src/plugins/blog/index.ts +22 -5
- package/src/plugins/random-quote/AGENTS.md +30 -7
- package/src/plugins/random-quote/index.ts +17 -1
- package/src/plugins/random-quote/public_assets/widget.css +5 -0
- package/src/plugins/sitemap/AGENTS.md +82 -0
- package/src/plugins/sitemap/index.ts +156 -0
- package/AGENTS.md +0 -87
- package/dist/modules/blog/module.d.ts +0 -20
- package/dist/modules/blog/module.d.ts.map +0 -1
- package/dist/modules/blog/module.js +0 -52
- package/dist/modules/blog/module.js.map +0 -1
- package/dist/modules/blog/posts.d.ts +0 -15
- package/dist/modules/blog/posts.d.ts.map +0 -1
- package/dist/modules/blog/posts.js +0 -46
- package/dist/modules/blog/posts.js.map +0 -1
- package/dist/modules.d.ts +0 -18
- package/dist/modules.d.ts.map +0 -1
- package/dist/modules.js +0 -25
- package/dist/modules.js.map +0 -1
- package/dist/plugins/blog/module.d.ts +0 -20
- package/dist/plugins/blog/module.d.ts.map +0 -1
- package/dist/plugins/blog/module.js +0 -52
- package/dist/plugins/blog/module.js.map +0 -1
- package/dist/plugins/blog/plugin.d.ts +0 -20
- package/dist/plugins/blog/plugin.d.ts.map +0 -1
- package/dist/plugins/blog/plugin.js +0 -52
- package/dist/plugins/blog/plugin.js.map +0 -1
- package/dist/plugins/random-quote/module.d.ts +0 -9
- package/dist/plugins/random-quote/module.d.ts.map +0 -1
- package/dist/plugins/random-quote/module.js +0 -31
- package/dist/plugins/random-quote/module.js.map +0 -1
- package/dist/plugins/random-quote/plugin.d.ts +0 -8
- package/dist/plugins/random-quote/plugin.d.ts.map +0 -1
- package/dist/plugins/random-quote/plugin.js +0 -31
- package/dist/plugins/random-quote/plugin.js.map +0 -1
- package/dist/plugins/random-quote/quotes.json +0 -230
- package/dist/public/_sb/plugins/random-quote/quotes.json +0 -230
- package/src/plugins/random-quote/public_assets/quotes.json +0 -230
- /package/{dist/plugins/random-quote/public_assets → src/plugins/random-quote/assets}/quotes.json +0 -0
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join, resolve, sep } from "node:path";
|
|
3
|
+
export class PluginError extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "PluginError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function requireNonEmptyString(value, label) {
|
|
10
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
11
|
+
throw new PluginError(`createPlugin(): ${label} is required`);
|
|
12
|
+
}
|
|
13
|
+
return value.trim();
|
|
14
|
+
}
|
|
15
|
+
function assertSafePluginName(name) {
|
|
16
|
+
if (name === "." ||
|
|
17
|
+
name === ".." ||
|
|
18
|
+
name.includes("/") ||
|
|
19
|
+
name.includes("\\")) {
|
|
20
|
+
throw new PluginError(`createPlugin(): name must be a single path segment (got "${name}")`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function requireKeywords(value) {
|
|
24
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
25
|
+
throw new PluginError("createPlugin(): keywords must be a non-empty array of strings");
|
|
26
|
+
}
|
|
27
|
+
const keywords = value.map((keyword, index) => {
|
|
28
|
+
if (typeof keyword !== "string" || keyword.trim().length === 0) {
|
|
29
|
+
throw new PluginError(`createPlugin(): keywords[${index}] must be a non-empty string`);
|
|
30
|
+
}
|
|
31
|
+
return keyword.trim();
|
|
32
|
+
});
|
|
33
|
+
return Object.freeze(keywords);
|
|
34
|
+
}
|
|
35
|
+
function requireRootDir(root) {
|
|
36
|
+
return resolve(requireNonEmptyString(root, "root"));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* When a plugin is compiled to `dist/plugins/<folder>`, `assets/` and
|
|
40
|
+
* `public_assets/` may still live next to the TypeScript source.
|
|
41
|
+
* Uses the on-disk folder name, which can differ from `plugin.name`.
|
|
42
|
+
*/
|
|
43
|
+
function sourcePluginSubdir(root, folder) {
|
|
44
|
+
const needle = `${sep}dist${sep}plugins${sep}`;
|
|
45
|
+
const index = root.lastIndexOf(needle);
|
|
46
|
+
if (index === -1) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const dirName = root.slice(index + needle.length).split(sep)[0];
|
|
50
|
+
if (!dirName) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const candidate = join(root.slice(0, index), "src", "plugins", dirName, folder);
|
|
54
|
+
return existsSync(candidate) ? candidate : null;
|
|
55
|
+
}
|
|
56
|
+
function resolvePluginSubdir(root, folder) {
|
|
57
|
+
const local = join(root, folder);
|
|
58
|
+
if (existsSync(local)) {
|
|
59
|
+
return local;
|
|
60
|
+
}
|
|
61
|
+
return sourcePluginSubdir(root, folder) ?? local;
|
|
62
|
+
}
|
|
63
|
+
export function createPlugin(options) {
|
|
64
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
65
|
+
throw new PluginError("createPlugin(): name, description, version, keywords, and root are required");
|
|
66
|
+
}
|
|
67
|
+
const name = requireNonEmptyString(options.name, "name");
|
|
68
|
+
assertSafePluginName(name);
|
|
69
|
+
const description = requireNonEmptyString(options.description, "description");
|
|
70
|
+
const version = requireNonEmptyString(options.version, "version");
|
|
71
|
+
const keywords = requireKeywords(options.keywords);
|
|
72
|
+
const root = requireRootDir(options.root);
|
|
73
|
+
return {
|
|
74
|
+
__kind: "plugin",
|
|
75
|
+
name,
|
|
76
|
+
description,
|
|
77
|
+
version,
|
|
78
|
+
keywords,
|
|
79
|
+
root,
|
|
80
|
+
assetsDir: resolvePluginSubdir(root, "assets"),
|
|
81
|
+
publicAssetsDir: resolvePluginSubdir(root, "public_assets"),
|
|
82
|
+
...(options.routes ? { routes: options.routes } : {}),
|
|
83
|
+
...(options.build ? { build: options.build } : {}),
|
|
84
|
+
...(options.hooks ? { hooks: options.hooks } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function isPlugin(value) {
|
|
88
|
+
return (typeof value === "object" &&
|
|
89
|
+
value !== null &&
|
|
90
|
+
value.__kind === "plugin" &&
|
|
91
|
+
typeof value.name === "string" &&
|
|
92
|
+
value.name.length > 0 &&
|
|
93
|
+
typeof value.description === "string" &&
|
|
94
|
+
value.description.length > 0 &&
|
|
95
|
+
typeof value.version === "string" &&
|
|
96
|
+
value.version.length > 0 &&
|
|
97
|
+
Array.isArray(value.keywords) &&
|
|
98
|
+
value.keywords.length > 0 &&
|
|
99
|
+
typeof value.root === "string" &&
|
|
100
|
+
typeof value.assetsDir === "string" &&
|
|
101
|
+
typeof value.publicAssetsDir === "string");
|
|
102
|
+
}
|
|
103
|
+
export function assertPlugin(value, label = "plugin") {
|
|
104
|
+
if (!isPlugin(value)) {
|
|
105
|
+
throw new PluginError(`${label}: each plugin must be created with createPlugin() and include name, description, version, and keywords`);
|
|
106
|
+
}
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
function copyDirIfPresent(source, dest) {
|
|
110
|
+
if (!existsSync(source) || !statSync(source).isDirectory()) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (resolve(source) === resolve(dest)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
mkdirSync(dest, { recursive: true });
|
|
117
|
+
cpSync(source, dest, { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Copy each registered plugin's private `assets/` next to its compiled entry
|
|
121
|
+
* (`{plugin.root}/assets`). Used by this package's build — not a site public copy.
|
|
122
|
+
*/
|
|
123
|
+
export function copyPluginPrivateAssets(plugins) {
|
|
124
|
+
for (const plugin of plugins) {
|
|
125
|
+
assertPlugin(plugin, "copyPluginPrivateAssets()");
|
|
126
|
+
copyDirIfPresent(plugin.assetsDir, join(plugin.root, "assets"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Copy each registered plugin's `public_assets/` to
|
|
131
|
+
* `{publicDir}/_sb/plugins/{name}/`. Only plugins you pass in are copied.
|
|
132
|
+
*/
|
|
133
|
+
export function copyRegisteredPluginAssets(plugins, publicDir) {
|
|
134
|
+
const destRoot = requireNonEmptyString(publicDir, "publicDir");
|
|
135
|
+
const seen = new Set();
|
|
136
|
+
for (const plugin of plugins) {
|
|
137
|
+
assertPlugin(plugin, "copyRegisteredPluginAssets()");
|
|
138
|
+
if (seen.has(plugin.name)) {
|
|
139
|
+
throw new PluginError(`copyRegisteredPluginAssets(): duplicate plugin name "${plugin.name}"`);
|
|
140
|
+
}
|
|
141
|
+
seen.add(plugin.name);
|
|
142
|
+
copyDirIfPresent(plugin.publicAssetsDir, join(destRoot, "_sb", "plugins", plugin.name));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Run each registered plugin's `build` hook (e.g. write sitemap.xml).
|
|
147
|
+
*/
|
|
148
|
+
export async function runRegisteredPluginBuilds(plugins, ctx) {
|
|
149
|
+
for (const plugin of plugins) {
|
|
150
|
+
assertPlugin(plugin, "runRegisteredPluginBuilds()");
|
|
151
|
+
if (plugin.build) {
|
|
152
|
+
await plugin.build(ctx);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/C,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,SAAS,qBAAqB,CAAC,KAAc,EAAE,KAAa;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,WAAW,CAAC,mBAAmB,KAAK,cAAc,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,IACE,IAAI,KAAK,GAAG;QACZ,IAAI,KAAK,IAAI;QACb,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EACnB,CAAC;QACD,MA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C,MAAM,EAAE,8BAA8B,CAAC,CAAC;QACrD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,WAAW,CACnB,wDAAwD,MAAM,CAAC,IAAI,GAAG,CACvE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,gBAAgB,CACd,MAAM,CAAC,eAAe,EACtB,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAC9C,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAA6B,EAC7B,GAA0B;IAE1B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,YAAY,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;QACpD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DefaultSlotContent } from "../../slot-content.js";
|
|
1
|
+
import type { Stackbox as SB } from "../../types.js";
|
|
3
2
|
import { type BlogOptions } from "./posts.js";
|
|
3
|
+
declare const _default: SB.Plugin;
|
|
4
|
+
export default _default;
|
|
4
5
|
export type { BlogPost, BlogOptions } from "./posts.js";
|
|
5
6
|
export type BlogPostContent = {
|
|
6
7
|
path: string;
|
|
7
8
|
title: string;
|
|
8
|
-
meta?: PageMeta;
|
|
9
|
-
content: DefaultSlotContent[];
|
|
9
|
+
meta?: SB.PageMeta;
|
|
10
|
+
content: SB.DefaultSlotContent[];
|
|
10
11
|
};
|
|
11
12
|
export type BlogListingContent = {
|
|
12
13
|
path: string;
|
|
13
|
-
content: DefaultSlotContent[];
|
|
14
|
+
content: SB.DefaultSlotContent[];
|
|
14
15
|
};
|
|
15
16
|
export type Blog = {
|
|
16
17
|
readonly posts: readonly BlogPostContent[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/blog/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/blog/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAa,KAAK,WAAW,EAAiB,MAAM,YAAY,CAAC;;AAExE,wBAeG;AAEH,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC;IACnB,OAAO,EAAE,EAAE,CAAC,kBAAkB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,EAAE,CAAC,kBAAkB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAClD,CAAC;AAwDF,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAQrD"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { createPlugin } from "../../plugin.js";
|
|
1
2
|
import { loadPosts } from "./posts.js";
|
|
3
|
+
export default createPlugin({
|
|
4
|
+
name: "sb-blog",
|
|
5
|
+
description: "Load markdown posts at bundle time and return listing and post content objects to wire into createPage().",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
keywords: [
|
|
8
|
+
"blog",
|
|
9
|
+
"posts",
|
|
10
|
+
"articles",
|
|
11
|
+
"journal",
|
|
12
|
+
"markdown posts",
|
|
13
|
+
"blog listing",
|
|
14
|
+
"blog page",
|
|
15
|
+
],
|
|
16
|
+
root: import.meta.dirname,
|
|
17
|
+
});
|
|
2
18
|
function postToContent(post) {
|
|
3
19
|
return {
|
|
4
20
|
path: post.path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/blog/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/blog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAmC,MAAM,YAAY,CAAC;AAExE,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,SAAS;IACf,WAAW,EACT,2GAA2G;IAC7G,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE;QACR,MAAM;QACN,OAAO;QACP,UAAU;QACV,SAAS;QACT,gBAAgB;QAChB,cAAc;QACd,WAAW;KACZ;IACD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO;CAC1B,CAAC,CAAC;AAqBH,SAAS,aAAa,CAAC,IAAc;IACnC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QACtE,OAAO,EAAE;YACP,mDAAmD,IAAI,CAAC,IAAI;QAC1D,IAAI,CAAC,KAAK;IACd,IAAI,CAAC,QAAQ;WACN;SACN;KACF,CAAC;AACJ,CAAC;AAED,SAAS,WAAW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AU,CAAC,OAAoB;IAC7C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAEjE,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;QAChC,QAAQ,EAAE,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC;KACtE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"text": "You can beat 40 scholars with one fact, but you can't beat one idiot with 40 facts.",
|
|
4
|
+
"author": "Rumi"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"text": "You will observe with concern how long a useful truth may be known and exist before it is generally recieved and practices on",
|
|
8
|
+
"author": "Benjamin Franklin"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"text": "Life can only be understood backwards; but it must be lived forwards.",
|
|
12
|
+
"author": "Søren Kierkegaard"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"text": "We are what we repeatedly do. Excellence, then, is not an act, but a habit.",
|
|
16
|
+
"author": "Will Durant"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"text": "Time has a wonderful way of showing us what really matters.",
|
|
20
|
+
"author": "Margaret Peters"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"text": "When a person can't find a deep sense of meaning, they distract themselves with pleasure.",
|
|
24
|
+
"author": "Viktor Frankl"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"text": "To attain knowledge, add things everyday. To attain wisdom, remove things every day.",
|
|
28
|
+
"author": "Lao Tzu"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"text": "At the end of the day, we can endure much more than we think we can.",
|
|
32
|
+
"author": "Frida Kahlo"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"text": "People rarely succeed unless they have fun in what they are doing.",
|
|
36
|
+
"author": "Dale Carnegie"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"text": "If you don't design your own life plan, chances are you'll fall into someone else's plan.",
|
|
40
|
+
"author": "Jim Rohn"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"text": "Not everything that is faced can be changed, but nothing can be changed until it is faced.",
|
|
44
|
+
"author": "James Baldwin"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"text": "The surface of the Earth is the shore of the cosmic ocean.",
|
|
48
|
+
"author": "Carl Sagan"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"text": "I do not feel obliged to believe that that same God who has endowed us with senses, reason, and intellect has intended to forgo their use",
|
|
52
|
+
"author": "Galileo Galilei"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"text": "In science the authority embodied in the opinion of thousands is not worth a spark of reason in one man.",
|
|
56
|
+
"author": "Galileo Galilei"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"text": "Mathematics is the language in which God wrote the universe.",
|
|
60
|
+
"author": "Galileo Galilei"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"text": "Ignorance is preferable to error; and he is less remote from the truth who believes nothing, than he who believes what is wrong.",
|
|
64
|
+
"author": "Thomas Jefferson"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"text": "The essence of Government is power; and power, lodged as it must be in human hands, will ever be liable to abuse.",
|
|
68
|
+
"author": "James Madison"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"text": "A workman who wants to do his work well must first prepare his tools.",
|
|
72
|
+
"author": "Confucius"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"text": "It is only the very wisest and the very stupidest who cannot change.",
|
|
76
|
+
"author": "Confucius"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"text": "Our wretched species is so made that those who walk on the well-trodden path always throw stones at those who are showing a new road.",
|
|
80
|
+
"author": "Voltaire"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"text": "I have always thought the actions of men the best interpreters of their thoughts.",
|
|
84
|
+
"author": "John Locke"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"text": "There are two tragedies in life. One is not to get your heart's desire. The other is to get it.",
|
|
88
|
+
"author": "George Bernard Shaw"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"text": "Marriage is the only adventure open to the cowardly.",
|
|
92
|
+
"author": "Voltaire"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"text": "Even the rich are hungry for love, for being cared for, for being wanted, for having someone to call their own.",
|
|
96
|
+
"author": "Mother Teresa"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"text": "Loneliness and the feeling of being unwanted is the most terrible poverty.",
|
|
100
|
+
"author": "Mother Teresa"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"text": "To know what life is worth you have to risk it once in a while.",
|
|
104
|
+
"author": "Jean-Paul Sartre"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"text": "Conformity is the jailer of freedom and the enemy of growth.",
|
|
108
|
+
"author": "John F. Kennedy"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"text": "Man is not born to solve the problem of the universe, but to find out what he has to do; and to restrain himself within the limits of his comprehension.",
|
|
112
|
+
"author": "Goethe"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"text": "Love does not dominate, it cultivates. And that is more.",
|
|
116
|
+
"author": "Goethe"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"text": "He alone is great and happy who fills his own station of independence, and has neither to command nor to obey.",
|
|
120
|
+
"author": "Goethe"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"text": "If you wish to advance into the infinite, explore the finite in all directions.",
|
|
124
|
+
"author": "Goethe"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"text": "One ought to hold on to one's heart; for if one lets it go, one soon loses control of the head too.",
|
|
128
|
+
"author": "Friedrich Nietzsche"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"text": "A faith is a necessity to man. Woe to him who believes nothing.",
|
|
132
|
+
"author": "Victor Hugo"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"text": "To live a life which is a perpetual falsehood is to suffer unknown tortures.",
|
|
136
|
+
"author": "Victor Hugo"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"text": "A man may be a fine genius, and yet understand nothing of an art which he has not studied.",
|
|
140
|
+
"author": "Victor Hugo"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"text": "How much more grievous are the consequences of anger than the causes of it.",
|
|
144
|
+
"author": "Marcus Aurelius"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"text": "You always own the option of having no opinion. There is never any need to get worked up or to trouble your soul about things you can't control. These things are not asking to be judged by you. Leave them alone.",
|
|
148
|
+
"author": "Marcus Aurelius"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"text": "It never ceases to amaze me: we all love ourselves more than other people, but care more about their opinions than our own.",
|
|
152
|
+
"author": "Marcus Aurelius"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"text": "External things are not the problem. It's your assessment of them. Which you can erase right now.",
|
|
156
|
+
"author": "Marcus Aurelius"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"text": "The man who reads nothing at all is more educated than the man who reads nothing but newspapers.",
|
|
160
|
+
"author": "Thomas Jefferson"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"text": "Nothing gives one person so much advantage over anohter as to remain always cool and unruffled under all circumstances.",
|
|
164
|
+
"author": "Thomas Jefferson"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"text": "Doubt is an uncomfortable condition, but certainty is a ridiculous one.",
|
|
168
|
+
"author": "Voltaire"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"text": "The longer we dwell on our misfortunes, the greater is their power to harm us.",
|
|
172
|
+
"author": "Voltaire"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"text": "Those who can make you believe absurdities, can make you commit atrocities.",
|
|
176
|
+
"author": "Voltaire"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"text": "It is dangerous to be right in matters on which the established authorities are wrong.",
|
|
180
|
+
"author": "Voltaire"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"text": "One can stand anything except a succession of ordinary days.",
|
|
184
|
+
"author": "Goethe"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"text": "Good times become good memories and bad times become good lessons in life.",
|
|
188
|
+
"author": "Unknown"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"text": "It's better to have a short life that is full of what you like doing, than a long life spent in a miserable way.",
|
|
192
|
+
"author": "Alan Watts"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"text": "To have faith is to trust yourself to the water. When you swim you don't grab hold of the water, because if you do you will sink and drown. Instead you relax, and float.",
|
|
196
|
+
"author": "Alan Watts"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"text": "I've been searching for years for the ideal place. And I've come to the realization that the only way to find it is to be it.",
|
|
200
|
+
"author": "Alan Watts"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"text": "I would rather be governed by the first 2,000 people in the Boston telephone directory than by the 2,000 people on the faculty of Harvard University.",
|
|
204
|
+
"author": "William F. Buckley Jr."
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"text": "Never confuse education with intelligence, you can have a PhD and still be an idiot.",
|
|
208
|
+
"author": "Richard Feynman"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"text": "The enemy is anybody who's going to get you killed, no matter which side he's on.",
|
|
212
|
+
"author": "Joseph Heller"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"text": "People often say motivation doesn't last. Neither does bathing—that's why we recommend it daily.",
|
|
216
|
+
"author": "Zig Ziglar"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"text": "Live free ot die; death is not the worst of evils.",
|
|
220
|
+
"author": "General John Stark"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"text": "Equality only exists in theory. Social law can give all men equal rights. Nature will never give them equal faculties.",
|
|
224
|
+
"author": "Napoleon"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"text": "One who does not want to reason exists as a fanatic; one who ignores how to reason exists as a fool; and one who will not dare to reason exists as a slave.",
|
|
228
|
+
"author": "Carlos Drummond de Andrade"
|
|
229
|
+
}
|
|
230
|
+
]
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare const _default: import("../../types.js").Stackbox.Plugin;
|
|
2
|
+
export default _default;
|
|
1
3
|
export type Quote = {
|
|
2
4
|
text: string;
|
|
3
5
|
author: string;
|
|
@@ -8,5 +10,5 @@ export type RandomQuoteBlockOptions = {
|
|
|
8
10
|
};
|
|
9
11
|
export declare const defaultQuotes: readonly Quote[];
|
|
10
12
|
export declare function pickRandomQuote(quotes: readonly Quote[]): Quote;
|
|
11
|
-
export declare const randomQuoteBlock: import("../../
|
|
13
|
+
export declare const randomQuoteBlock: import("../../types.js").Stackbox.BlockFactory<RandomQuoteBlockOptions | undefined>;
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/random-quote/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/random-quote/index.ts"],"names":[],"mappings":";AAKA,wBAaG;AAEH,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,mDAAmD;IACnD,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,SAAS,KAAK,EAAkB,CAAC;AAE7D,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,KAAK,CAK/D;AAED,eAAO,MAAM,gBAAgB,qFAS3B,CAAC"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { html } from "@hyperspan/html";
|
|
2
2
|
import { createBlock } from "../../blocks.js";
|
|
3
|
-
import
|
|
3
|
+
import { createPlugin } from "../../plugin.js";
|
|
4
|
+
import bundledQuotes from "./assets/quotes.json" with { type: "json" };
|
|
5
|
+
export default createPlugin({
|
|
6
|
+
name: "sb-random-quote",
|
|
7
|
+
description: "A block that renders a random inspirational quote, using bundled defaults or a site-supplied list.",
|
|
8
|
+
version: "1.0.0",
|
|
9
|
+
keywords: [
|
|
10
|
+
"random quote",
|
|
11
|
+
"quote of the day",
|
|
12
|
+
"inspirational quote",
|
|
13
|
+
"sidebar quote",
|
|
14
|
+
"quotation",
|
|
15
|
+
],
|
|
16
|
+
root: import.meta.dirname,
|
|
17
|
+
});
|
|
4
18
|
export const defaultQuotes = bundledQuotes;
|
|
5
19
|
export function pickRandomQuote(quotes) {
|
|
6
20
|
if (quotes.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/random-quote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/random-quote/index.ts"],"names":[],"mappings":"AAAA,OA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origin. Defaults to `siteConfig.config.url`. */
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
/** Extra site-relative or absolute URLs. */
|
|
6
|
+
extraUrls?: readonly string[];
|
|
7
|
+
exclude?: readonly string[] | ((path: string) => boolean);
|
|
8
|
+
};
|
|
9
|
+
export declare function collectSitemapUrls(site: SB.Site, options?: SitemapOptions): string[];
|
|
10
|
+
export declare function renderSitemapXml(site: SB.Site, options?: SitemapOptions): string;
|
|
11
|
+
export declare function createSitemap(options?: SitemapOptions): SB.Plugin;
|
|
12
|
+
declare const _default: SB.Plugin;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/sitemap/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG;IAC3B,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAC3D,CAAC;AAkCF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,GAAE,cAAmB,GAC3B,MAAM,EAAE,CA4BV;AAWD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,GAAE,cAAmB,GAC3B,MAAM,CAMR;AAgCD,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB,GAAG,EAAE,CAAC,MAAM,CAsBrE;;AAED,wBAA+B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { createPlugin, } from "../../plugin.js";
|
|
4
|
+
import { normalizePathname } from "../../routing.js";
|
|
5
|
+
function resolveBaseUrl(site, options) {
|
|
6
|
+
const raw = options.baseUrl ?? site.siteConfig.config.url;
|
|
7
|
+
if (typeof raw !== "string" || raw.trim().length === 0) {
|
|
8
|
+
throw new Error("sb-sitemap: baseUrl or siteConfig.url is required");
|
|
9
|
+
}
|
|
10
|
+
const url = raw.trim().replace(/\/+$/, "");
|
|
11
|
+
try {
|
|
12
|
+
new URL(url);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error(`sb-sitemap: invalid base URL "${raw}"`);
|
|
16
|
+
}
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
function isExcluded(path, options) {
|
|
20
|
+
const normalized = normalizePathname(path);
|
|
21
|
+
if (!options.exclude) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (typeof options.exclude === "function") {
|
|
25
|
+
return options.exclude(normalized);
|
|
26
|
+
}
|
|
27
|
+
return options.exclude.some((entry) => normalizePathname(entry) === normalized);
|
|
28
|
+
}
|
|
29
|
+
function isNoindexPage(page) {
|
|
30
|
+
const robots = page.meta?.robots?.toLowerCase() ?? "";
|
|
31
|
+
return robots.includes("noindex");
|
|
32
|
+
}
|
|
33
|
+
export function collectSitemapUrls(site, options = {}) {
|
|
34
|
+
const base = resolveBaseUrl(site, options);
|
|
35
|
+
const locs = new Set();
|
|
36
|
+
for (const page of site.pages) {
|
|
37
|
+
if (isNoindexPage(page)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (isExcluded(page.path, options)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
locs.add(`${base}${normalizePathname(page.path)}`);
|
|
44
|
+
}
|
|
45
|
+
for (const extra of options.extraUrls ?? []) {
|
|
46
|
+
if (extra.startsWith("http://") || extra.startsWith("https://")) {
|
|
47
|
+
if (!isExcluded(extra, options)) {
|
|
48
|
+
locs.add(extra);
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const path = normalizePathname(extra);
|
|
53
|
+
if (!isExcluded(path, options)) {
|
|
54
|
+
locs.add(`${base}${path}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return [...locs].sort();
|
|
58
|
+
}
|
|
59
|
+
function escapeXml(text) {
|
|
60
|
+
return text
|
|
61
|
+
.replace(/&/g, "&")
|
|
62
|
+
.replace(/</g, "<")
|
|
63
|
+
.replace(/>/g, ">")
|
|
64
|
+
.replace(/"/g, """)
|
|
65
|
+
.replace(/'/g, "'");
|
|
66
|
+
}
|
|
67
|
+
export function renderSitemapXml(site, options = {}) {
|
|
68
|
+
const urls = collectSitemapUrls(site, options);
|
|
69
|
+
const body = urls
|
|
70
|
+
.map((loc) => ` <url>\n <loc>${escapeXml(loc)}</loc>\n </url>`)
|
|
71
|
+
.join("\n");
|
|
72
|
+
return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${body}\n</urlset>\n`;
|
|
73
|
+
}
|
|
74
|
+
function sitemapResponse(request, xml) {
|
|
75
|
+
const headers = { "content-type": "application/xml; charset=utf-8" };
|
|
76
|
+
if (request.method === "HEAD") {
|
|
77
|
+
const bytes = new TextEncoder().encode(xml);
|
|
78
|
+
return new globalThis.Response(null, {
|
|
79
|
+
status: 200,
|
|
80
|
+
headers: { ...headers, "content-length": String(bytes.byteLength) },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return new globalThis.Response(xml, { status: 200, headers });
|
|
84
|
+
}
|
|
85
|
+
function createSitemapRoutes(ctx, options) {
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
path: "/sitemap.xml",
|
|
89
|
+
fetch(request) {
|
|
90
|
+
const xml = renderSitemapXml(ctx.site, options);
|
|
91
|
+
return sitemapResponse(request, xml);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
export function createSitemap(options = {}) {
|
|
97
|
+
return createPlugin({
|
|
98
|
+
name: "sb-sitemap",
|
|
99
|
+
description: "Generate sitemap.xml from site pages for search engines and static deploys.",
|
|
100
|
+
version: "1.0.0",
|
|
101
|
+
keywords: [
|
|
102
|
+
"sitemap",
|
|
103
|
+
"sitemap.xml",
|
|
104
|
+
"seo",
|
|
105
|
+
"search engines",
|
|
106
|
+
"xml sitemap",
|
|
107
|
+
],
|
|
108
|
+
root: import.meta.dirname,
|
|
109
|
+
routes(ctx) {
|
|
110
|
+
return createSitemapRoutes(ctx, options);
|
|
111
|
+
},
|
|
112
|
+
build(ctx) {
|
|
113
|
+
const xml = renderSitemapXml(ctx.site, options);
|
|
114
|
+
writeFileSync(join(ctx.publicDir, "sitemap.xml"), xml, "utf8");
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export default createSitemap();
|
|
119
|
+
//# sourceMappingURL=index.js.map
|