@binarynoir/vite-plugin-blog 0.0.0-stage → 0.2.0
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 +21 -0
- package/README.md +224 -2
- package/client.d.ts +27 -0
- package/dist/index.cjs +1199 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +232 -0
- package/dist/index.d.ts +232 -0
- package/dist/index.js +1163 -0
- package/dist/index.js.map +1 -0
- package/package.json +90 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
BUILT_IN_DIRECTIVES: () => BUILT_IN_DIRECTIVES,
|
|
34
|
+
blog: () => blog,
|
|
35
|
+
default: () => blog,
|
|
36
|
+
escapeHtml: () => escapeHtml,
|
|
37
|
+
slugify: () => slugify
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
|
+
|
|
41
|
+
// src/plugin.ts
|
|
42
|
+
var import_node_fs3 = require("fs");
|
|
43
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
44
|
+
|
|
45
|
+
// src/content.ts
|
|
46
|
+
var import_node_fs2 = require("fs");
|
|
47
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
48
|
+
var import_yaml2 = require("yaml");
|
|
49
|
+
|
|
50
|
+
// src/dates.ts
|
|
51
|
+
var DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?\s*(Z|[+-]\d{2}:?\d{2})?$/i;
|
|
52
|
+
function isTimeZone(timeZone) {
|
|
53
|
+
try {
|
|
54
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
55
|
+
return true;
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
var warnedZones = /* @__PURE__ */ new Set();
|
|
61
|
+
function resolveTimeZone(timeZone) {
|
|
62
|
+
if (!timeZone) return "UTC";
|
|
63
|
+
if (isTimeZone(timeZone)) return timeZone;
|
|
64
|
+
if (!warnedZones.has(timeZone)) {
|
|
65
|
+
warnedZones.add(timeZone);
|
|
66
|
+
console.warn(
|
|
67
|
+
`[vite-plugin-blog] "${timeZone}" is not a time zone; using UTC. Use an IANA name such as "America/New_York".`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return "UTC";
|
|
71
|
+
}
|
|
72
|
+
var offsetFormats = /* @__PURE__ */ new Map();
|
|
73
|
+
function zoneOffset(instant, timeZone) {
|
|
74
|
+
let format = offsetFormats.get(timeZone);
|
|
75
|
+
if (!format) {
|
|
76
|
+
format = new Intl.DateTimeFormat("en-US", {
|
|
77
|
+
timeZone,
|
|
78
|
+
hourCycle: "h23",
|
|
79
|
+
year: "numeric",
|
|
80
|
+
month: "2-digit",
|
|
81
|
+
day: "2-digit",
|
|
82
|
+
hour: "2-digit",
|
|
83
|
+
minute: "2-digit",
|
|
84
|
+
second: "2-digit"
|
|
85
|
+
});
|
|
86
|
+
offsetFormats.set(timeZone, format);
|
|
87
|
+
}
|
|
88
|
+
const parts = Object.fromEntries(
|
|
89
|
+
format.formatToParts(instant).map(({ type, value }) => [type, Number(value)])
|
|
90
|
+
);
|
|
91
|
+
const wall = Date.UTC(
|
|
92
|
+
parts.year,
|
|
93
|
+
parts.month - 1,
|
|
94
|
+
parts.day,
|
|
95
|
+
parts.hour,
|
|
96
|
+
parts.minute,
|
|
97
|
+
parts.second
|
|
98
|
+
);
|
|
99
|
+
return wall - Math.floor(instant / 1e3) * 1e3;
|
|
100
|
+
}
|
|
101
|
+
function fromZonedTime(wall, timeZone) {
|
|
102
|
+
const first = wall - zoneOffset(wall, timeZone);
|
|
103
|
+
const second = wall - zoneOffset(first, timeZone);
|
|
104
|
+
return second;
|
|
105
|
+
}
|
|
106
|
+
function parsePostDate(value, timeZone = "UTC") {
|
|
107
|
+
if (value instanceof Date) {
|
|
108
|
+
if (Number.isNaN(value.getTime())) return null;
|
|
109
|
+
const midnight = value.getUTCHours() === 0 && value.getUTCMinutes() === 0 && value.getUTCSeconds() === 0;
|
|
110
|
+
return { date: value, hasTime: !midnight };
|
|
111
|
+
}
|
|
112
|
+
if (typeof value !== "string") return null;
|
|
113
|
+
const match = DATE_TIME.exec(value.trim());
|
|
114
|
+
if (!match) return null;
|
|
115
|
+
const [, year, month, day, hour, minute, second = "0", millisecond = "0", offset] = match;
|
|
116
|
+
const hasTime = hour !== void 0;
|
|
117
|
+
const wall = Date.UTC(
|
|
118
|
+
Number(year),
|
|
119
|
+
Number(month) - 1,
|
|
120
|
+
Number(day),
|
|
121
|
+
hasTime ? Number(hour) : 0,
|
|
122
|
+
hasTime ? Number(minute) : 0,
|
|
123
|
+
Number(second),
|
|
124
|
+
Number(millisecond.padEnd(3, "0"))
|
|
125
|
+
);
|
|
126
|
+
const check = new Date(wall);
|
|
127
|
+
if (check.getUTCMonth() !== Number(month) - 1 || check.getUTCDate() !== Number(day)) return null;
|
|
128
|
+
if (!offset) return { date: new Date(fromZonedTime(wall, timeZone)), hasTime };
|
|
129
|
+
if (offset.toUpperCase() === "Z") return { date: new Date(wall), hasTime };
|
|
130
|
+
const sign = offset.startsWith("-") ? -1 : 1;
|
|
131
|
+
const digits = offset.slice(1).replace(":", "");
|
|
132
|
+
const minutes = Number(digits.slice(0, 2)) * 60 + Number(digits.slice(2));
|
|
133
|
+
return { date: new Date(wall - sign * minutes * 6e4), hasTime };
|
|
134
|
+
}
|
|
135
|
+
function formatPostDate({ date, hasTime }, display) {
|
|
136
|
+
const { locale, timeZone } = display;
|
|
137
|
+
const day = new Intl.DateTimeFormat(locale, { timeZone, ...display.dateFormat }).format(date);
|
|
138
|
+
if (!hasTime) return day;
|
|
139
|
+
const time = new Intl.DateTimeFormat(locale, { timeZone, ...display.timeFormat }).format(date);
|
|
140
|
+
return display.dateTime.replace("{date}", day).replace("{time}", time);
|
|
141
|
+
}
|
|
142
|
+
function toZonedIsoDate(date, timeZone) {
|
|
143
|
+
const parts = Object.fromEntries(
|
|
144
|
+
new Intl.DateTimeFormat("en-US", {
|
|
145
|
+
timeZone,
|
|
146
|
+
year: "numeric",
|
|
147
|
+
month: "2-digit",
|
|
148
|
+
day: "2-digit"
|
|
149
|
+
}).formatToParts(date).map(({ type, value }) => [type, value])
|
|
150
|
+
);
|
|
151
|
+
return `${parts.year}-${parts.month}-${parts.day}`;
|
|
152
|
+
}
|
|
153
|
+
function toDateTimeAttribute({ date, hasTime }, timeZone) {
|
|
154
|
+
return hasTime ? date.toISOString() : toZonedIsoDate(date, timeZone);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/highlight.ts
|
|
158
|
+
var import_transformers = require("@shikijs/transformers");
|
|
159
|
+
var import_shiki = require("shiki");
|
|
160
|
+
|
|
161
|
+
// src/util.ts
|
|
162
|
+
var import_yaml = require("yaml");
|
|
163
|
+
var HTML_ESCAPES = {
|
|
164
|
+
"&": "&",
|
|
165
|
+
"<": "<",
|
|
166
|
+
">": ">",
|
|
167
|
+
'"': """,
|
|
168
|
+
"'": "'"
|
|
169
|
+
};
|
|
170
|
+
function escapeHtml(value) {
|
|
171
|
+
return value.replace(/[&<>"']/g, (character) => HTML_ESCAPES[character]);
|
|
172
|
+
}
|
|
173
|
+
function isExternalUrl(url) {
|
|
174
|
+
return /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(url);
|
|
175
|
+
}
|
|
176
|
+
function joinUrl(base, path4) {
|
|
177
|
+
return `${base.replace(/\/+$/, "")}/${path4.replace(/^\/+/, "")}`;
|
|
178
|
+
}
|
|
179
|
+
function normalizeBase(base) {
|
|
180
|
+
const trimmed = base.replace(/^\/+|\/+$/g, "");
|
|
181
|
+
return trimmed ? `/${trimmed}/` : "/";
|
|
182
|
+
}
|
|
183
|
+
var FRONTMATTER = /^---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
|
|
184
|
+
function readFrontmatter(raw) {
|
|
185
|
+
const source = raw.replace(/^\uFEFF/, "");
|
|
186
|
+
const match = FRONTMATTER.exec(source);
|
|
187
|
+
if (!match) return { data: {}, content: source };
|
|
188
|
+
const data = match[1] ? (0, import_yaml.parse)(match[1], { schema: "core" }) : null;
|
|
189
|
+
return { data: toRecord(data), content: source.slice(match[0].length) };
|
|
190
|
+
}
|
|
191
|
+
function toRecord(value) {
|
|
192
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
193
|
+
}
|
|
194
|
+
function toText(value) {
|
|
195
|
+
return typeof value === "string" ? value.trim() : typeof value === "number" ? String(value) : "";
|
|
196
|
+
}
|
|
197
|
+
function toStringList(value) {
|
|
198
|
+
const values = Array.isArray(value) ? value : typeof value === "string" ? value.split(",") : [];
|
|
199
|
+
return values.map(toText).filter(Boolean);
|
|
200
|
+
}
|
|
201
|
+
function slugify(text) {
|
|
202
|
+
return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/&[a-z]+;/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/highlight.ts
|
|
206
|
+
var PLAIN = /* @__PURE__ */ new Set(["", "text", "txt", "plain", "plaintext"]);
|
|
207
|
+
function isBundled(lang) {
|
|
208
|
+
return Object.hasOwn(import_shiki.bundledLanguages, lang) || Object.hasOwn(import_shiki.bundledLanguagesAlias, lang);
|
|
209
|
+
}
|
|
210
|
+
function plainBlock(code, lang) {
|
|
211
|
+
const attr2 = lang ? ` data-lang="${escapeHtml(lang)}"` : "";
|
|
212
|
+
return `<pre class="shiki"${attr2}><code>${escapeHtml(code)}</code></pre>`;
|
|
213
|
+
}
|
|
214
|
+
async function createCodeHighlighter(options) {
|
|
215
|
+
const highlighter = await (0, import_shiki.createHighlighter)({
|
|
216
|
+
themes: [options.themes.light, options.themes.dark],
|
|
217
|
+
langs: []
|
|
218
|
+
});
|
|
219
|
+
const toClass = (0, import_transformers.transformerStyleToClass)({ classPrefix: options.classPrefix });
|
|
220
|
+
const loaded = /* @__PURE__ */ new Set();
|
|
221
|
+
return {
|
|
222
|
+
async load(langs) {
|
|
223
|
+
const unknown = [];
|
|
224
|
+
for (const raw of langs) {
|
|
225
|
+
const lang = raw.toLowerCase();
|
|
226
|
+
if (PLAIN.has(lang) || loaded.has(lang)) continue;
|
|
227
|
+
if (!isBundled(lang)) {
|
|
228
|
+
unknown.push(raw);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
await highlighter.loadLanguage(lang);
|
|
232
|
+
loaded.add(lang);
|
|
233
|
+
}
|
|
234
|
+
return unknown;
|
|
235
|
+
},
|
|
236
|
+
highlight(code, raw) {
|
|
237
|
+
const lang = raw.toLowerCase();
|
|
238
|
+
if (!loaded.has(lang)) return plainBlock(code, raw);
|
|
239
|
+
return highlighter.codeToHtml(code, {
|
|
240
|
+
lang,
|
|
241
|
+
themes: options.themes,
|
|
242
|
+
defaultColor: false,
|
|
243
|
+
transformers: [
|
|
244
|
+
toClass,
|
|
245
|
+
{
|
|
246
|
+
pre(node) {
|
|
247
|
+
node.properties["data-lang"] = raw;
|
|
248
|
+
delete node.properties.tabindex;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
css() {
|
|
255
|
+
return [
|
|
256
|
+
"/* Code highlighting from @binarynoir/vite-plugin-blog. Generated: do not edit. */",
|
|
257
|
+
".shiki { color: light-dark(var(--shiki-light), var(--shiki-dark)); background-color: light-dark(var(--shiki-light-bg), var(--shiki-dark-bg)); }",
|
|
258
|
+
".shiki span { color: light-dark(var(--shiki-light), var(--shiki-dark)); }",
|
|
259
|
+
toClass.getCSS(),
|
|
260
|
+
""
|
|
261
|
+
].join("\n");
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// src/markdown.ts
|
|
267
|
+
var import_node_fs = require("fs");
|
|
268
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
269
|
+
var import_image_size = require("image-size");
|
|
270
|
+
var import_markdown_it = __toESM(require("markdown-it"), 1);
|
|
271
|
+
|
|
272
|
+
// src/directives.ts
|
|
273
|
+
var OPENING = /^:::[ \t]*([a-z][\w-]*)(?:[ \t]+(.*?))?[ \t]*$/i;
|
|
274
|
+
var CLOSING = /^:::[ \t]*$/;
|
|
275
|
+
function callout(kind, label) {
|
|
276
|
+
return {
|
|
277
|
+
kind: "container",
|
|
278
|
+
render: ({ args, body }) => `<aside class="callout callout-${kind}">
|
|
279
|
+
<p class="callout-title">${escapeHtml(args || label)}</p>
|
|
280
|
+
${body}</aside>
|
|
281
|
+
`
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
var BUILT_IN_DIRECTIVES = {
|
|
285
|
+
note: callout("note", "Note"),
|
|
286
|
+
tip: callout("tip", "Tip"),
|
|
287
|
+
warning: callout("warning", "Warning")
|
|
288
|
+
};
|
|
289
|
+
function lineText(state, line) {
|
|
290
|
+
return state.src.slice(state.bMarks[line] + state.tShift[line], state.eMarks[line]);
|
|
291
|
+
}
|
|
292
|
+
function directivesPlugin(md, directives) {
|
|
293
|
+
md.block.ruler.before(
|
|
294
|
+
"fence",
|
|
295
|
+
"blog_directive",
|
|
296
|
+
(state, startLine, endLine, silent) => {
|
|
297
|
+
if (state.sCount[startLine] - state.blkIndent >= 4) return false;
|
|
298
|
+
const match = OPENING.exec(lineText(state, startLine));
|
|
299
|
+
if (!match) return false;
|
|
300
|
+
const name = match[1].toLowerCase();
|
|
301
|
+
const args = match[2] ?? "";
|
|
302
|
+
const directive = Object.hasOwn(directives, name) ? directives[name] : void 0;
|
|
303
|
+
if (silent) return true;
|
|
304
|
+
if (!directive || directive.kind === "leaf") {
|
|
305
|
+
const token = state.push("blog_directive", "", 0);
|
|
306
|
+
token.info = name;
|
|
307
|
+
token.meta = { args };
|
|
308
|
+
token.map = [startLine, startLine + 1];
|
|
309
|
+
state.line = startLine + 1;
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
let depth = 1;
|
|
313
|
+
let line = startLine + 1;
|
|
314
|
+
for (; line < endLine; line++) {
|
|
315
|
+
if (state.sCount[line] < state.blkIndent) break;
|
|
316
|
+
const text = lineText(state, line);
|
|
317
|
+
if (CLOSING.test(text)) {
|
|
318
|
+
if (--depth === 0) break;
|
|
319
|
+
} else {
|
|
320
|
+
const inner = OPENING.exec(text);
|
|
321
|
+
const innerName = inner?.[1]?.toLowerCase();
|
|
322
|
+
if (innerName && directives[innerName]?.kind === "container") depth++;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const closed = depth === 0;
|
|
326
|
+
const open = state.push("blog_directive_open", "", 1);
|
|
327
|
+
open.info = name;
|
|
328
|
+
open.meta = { args, closed };
|
|
329
|
+
open.map = [startLine, line];
|
|
330
|
+
open.block = true;
|
|
331
|
+
const oldParent = state.parentType;
|
|
332
|
+
const oldLineMax = state.lineMax;
|
|
333
|
+
state.parentType = "blog_directive";
|
|
334
|
+
state.lineMax = line;
|
|
335
|
+
state.md.block.tokenize(state, startLine + 1, line);
|
|
336
|
+
state.parentType = oldParent;
|
|
337
|
+
state.lineMax = oldLineMax;
|
|
338
|
+
const close = state.push("blog_directive_close", "", -1);
|
|
339
|
+
close.info = name;
|
|
340
|
+
close.block = true;
|
|
341
|
+
state.line = closed ? line + 1 : line;
|
|
342
|
+
return true;
|
|
343
|
+
},
|
|
344
|
+
{ alt: ["paragraph", "reference", "blockquote", "list"] }
|
|
345
|
+
);
|
|
346
|
+
const report = (env, line, message) => env.error(line === void 0 ? message : `line ${line + 1}: ${message}`);
|
|
347
|
+
md.renderer.rules.blog_directive = (tokens, index, _options, rawEnv) => {
|
|
348
|
+
const env = asEnv(rawEnv);
|
|
349
|
+
const token = tokens[index];
|
|
350
|
+
const directive = Object.hasOwn(directives, token.info) ? directives[token.info] : void 0;
|
|
351
|
+
const line = token.map?.[0] === void 0 ? void 0 : token.map[0] + env.lineOffset;
|
|
352
|
+
if (!directive) {
|
|
353
|
+
report(env, line, `unknown directive "::: ${token.info}"`);
|
|
354
|
+
return "";
|
|
355
|
+
}
|
|
356
|
+
return directive.render({
|
|
357
|
+
args: token.meta?.args ?? "",
|
|
358
|
+
body: "",
|
|
359
|
+
post: env.post,
|
|
360
|
+
md,
|
|
361
|
+
error: (message) => report(env, line, `::: ${token.info}: ${message}`)
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
md.renderer.rules.blog_directive_open = (tokens, index, options, rawEnv) => {
|
|
365
|
+
const env = asEnv(rawEnv);
|
|
366
|
+
const open = tokens[index];
|
|
367
|
+
const line = open.map?.[0] === void 0 ? void 0 : open.map[0] + env.lineOffset;
|
|
368
|
+
if (!open.meta?.closed) report(env, line, `"::: ${open.info}" has no closing ":::"`);
|
|
369
|
+
let depth = 0;
|
|
370
|
+
let end = index + 1;
|
|
371
|
+
for (; end < tokens.length; end++) {
|
|
372
|
+
const type = tokens[end].type;
|
|
373
|
+
if (type === "blog_directive_open") depth++;
|
|
374
|
+
else if (type === "blog_directive_close" && depth-- === 0) break;
|
|
375
|
+
}
|
|
376
|
+
const body = md.renderer.render(tokens.slice(index + 1, end), options, env);
|
|
377
|
+
for (let i = index + 1; i <= end && i < tokens.length; i++) {
|
|
378
|
+
tokens[i].hidden = true;
|
|
379
|
+
tokens[i].type = "blog_directive_rendered";
|
|
380
|
+
tokens[i].children = null;
|
|
381
|
+
tokens[i].content = "";
|
|
382
|
+
}
|
|
383
|
+
const directive = directives[open.info];
|
|
384
|
+
return directive.render({
|
|
385
|
+
args: open.meta?.args ?? "",
|
|
386
|
+
body,
|
|
387
|
+
post: env.post,
|
|
388
|
+
md,
|
|
389
|
+
error: (message) => report(env, line, `::: ${open.info}: ${message}`)
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
md.renderer.rules.blog_directive_rendered = () => "";
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/markdown.ts
|
|
396
|
+
function readSize(file) {
|
|
397
|
+
try {
|
|
398
|
+
const buffer = (0, import_node_fs.readFileSync)(file);
|
|
399
|
+
const { width, height } = (0, import_image_size.imageSize)(buffer);
|
|
400
|
+
return { width, height };
|
|
401
|
+
} catch {
|
|
402
|
+
return {};
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function asEnv(env) {
|
|
406
|
+
return env;
|
|
407
|
+
}
|
|
408
|
+
function attr(token, name) {
|
|
409
|
+
const value = token.attrGet(name);
|
|
410
|
+
return value === null ? void 0 : String(value);
|
|
411
|
+
}
|
|
412
|
+
function lineOf(token, env) {
|
|
413
|
+
return token.map ? `line ${token.map[0] + env.lineOffset + 1}: ` : "";
|
|
414
|
+
}
|
|
415
|
+
function headings(md) {
|
|
416
|
+
md.core.ruler.push("blog_headings", (state) => {
|
|
417
|
+
const env = asEnv(state.env);
|
|
418
|
+
const used = /* @__PURE__ */ new Map();
|
|
419
|
+
const tokens = state.tokens;
|
|
420
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
421
|
+
const open = tokens[i];
|
|
422
|
+
if (open.type !== "heading_open") continue;
|
|
423
|
+
const inline = tokens[i + 1];
|
|
424
|
+
const text = (inline.children ?? []).filter((child) => child.type === "text" || child.type === "code_inline").map((child) => child.content).join("").trim();
|
|
425
|
+
const base = attr(open, "id") ?? (slugify(text) || "section");
|
|
426
|
+
const count = used.get(base) ?? 0;
|
|
427
|
+
used.set(base, count + 1);
|
|
428
|
+
const id = count ? `${base}-${count}` : base;
|
|
429
|
+
open.attrSet("id", id);
|
|
430
|
+
const level = Number(open.tag.slice(1));
|
|
431
|
+
if (level === 2 || level === 3) env.toc.push({ level, id, text });
|
|
432
|
+
if (level === 1)
|
|
433
|
+
env.error(`${lineOf(open, env)}use the front matter title, not a "#" heading`);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
const defaultClose = md.renderer.rules.heading_close ?? ((tokens, index, options, _env, self) => self.renderToken(tokens, index, options));
|
|
437
|
+
md.renderer.rules.heading_close = (tokens, index, options, env, self) => {
|
|
438
|
+
const heading = tokens[index - 2];
|
|
439
|
+
const id = heading && attr(heading, "id");
|
|
440
|
+
const anchor = id ? ` <a class="heading-anchor" href="#${escapeHtml(id)}" aria-hidden="true" tabindex="-1">#</a>` : "";
|
|
441
|
+
return anchor + defaultClose(tokens, index, options, env, self);
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function images(md) {
|
|
445
|
+
md.core.ruler.push("blog_figures", (state) => {
|
|
446
|
+
const tokens = state.tokens;
|
|
447
|
+
for (let i = 0; i + 2 < tokens.length; i++) {
|
|
448
|
+
const [open, inline, close] = [tokens[i], tokens[i + 1], tokens[i + 2]];
|
|
449
|
+
if (open.type !== "paragraph_open" || close.type !== "paragraph_close") continue;
|
|
450
|
+
const children = (inline.children ?? []).filter(
|
|
451
|
+
(child) => !(child.type === "text" && !child.content.trim())
|
|
452
|
+
);
|
|
453
|
+
if (children.length !== 1 || children[0].type !== "image") continue;
|
|
454
|
+
open.hidden = true;
|
|
455
|
+
close.hidden = true;
|
|
456
|
+
children[0].meta = { ...children[0].meta, figure: true };
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
md.renderer.rules.image = (tokens, index, options, rawEnv, self) => {
|
|
460
|
+
const env = asEnv(rawEnv);
|
|
461
|
+
const token = tokens[index];
|
|
462
|
+
const alt = self.renderInlineAsText(token.children ?? [], options, env).trim();
|
|
463
|
+
const src = attr(token, "src") ?? "";
|
|
464
|
+
const title = attr(token, "title") ?? "";
|
|
465
|
+
const line = token.meta?.line;
|
|
466
|
+
const where = line ? `line ${line}: ` : "";
|
|
467
|
+
if (!alt) env.error(`${where}image "${src}" has no alt text`);
|
|
468
|
+
const attrs = [];
|
|
469
|
+
let url = src;
|
|
470
|
+
if (src && !isExternalUrl(src) && !src.startsWith("/") && !src.startsWith("data:")) {
|
|
471
|
+
const file = import_node_path.default.resolve(import_node_path.default.dirname(env.post.file), decodeURI(src.split(/[?#]/)[0]));
|
|
472
|
+
if (!(0, import_node_fs.existsSync)(file)) {
|
|
473
|
+
env.error(`${where}image "${src}" doesn't exist`);
|
|
474
|
+
} else {
|
|
475
|
+
env.images.push(file);
|
|
476
|
+
url = env.assetUrl(file);
|
|
477
|
+
const { width, height } = readSize(file);
|
|
478
|
+
if (width && height) attrs.push(`width="${width}"`, `height="${height}"`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
env.imageCount++;
|
|
482
|
+
if (env.imageCount > 1) attrs.push('loading="lazy"');
|
|
483
|
+
attrs.push('decoding="async"');
|
|
484
|
+
const img = `<img src="${escapeHtml(url)}" alt="${escapeHtml(alt)}" ${attrs.join(" ")}>`;
|
|
485
|
+
if (!token.meta?.figure) return img;
|
|
486
|
+
const caption = title ? `<figcaption>${md.renderInline(title, env)}</figcaption>` : "";
|
|
487
|
+
return `<figure>${img}${caption}</figure>
|
|
488
|
+
`;
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function links(md) {
|
|
492
|
+
md.core.ruler.push("blog_links", (state) => {
|
|
493
|
+
const env = asEnv(state.env);
|
|
494
|
+
for (const block of state.tokens) {
|
|
495
|
+
const line = block.map ? block.map[0] + env.lineOffset + 1 : void 0;
|
|
496
|
+
for (const child of block.children ?? []) {
|
|
497
|
+
if (child.type === "image") child.meta = { ...child.meta, line };
|
|
498
|
+
if (child.type !== "link_open") continue;
|
|
499
|
+
const href = attr(child, "href") ?? "";
|
|
500
|
+
if (href.startsWith("/") && !href.startsWith("//")) env.links.push({ href, line });
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
function fences(md, highlighter) {
|
|
506
|
+
md.renderer.rules.fence = (tokens, index) => {
|
|
507
|
+
const token = tokens[index];
|
|
508
|
+
const lang = token.info.trim().split(/\s+/)[0] ?? "";
|
|
509
|
+
const code = token.content;
|
|
510
|
+
const html = highlighter ? highlighter.highlight(code, lang) : plainBlock(code, lang);
|
|
511
|
+
const attr2 = lang ? ` data-lang="${escapeHtml(lang)}"` : "";
|
|
512
|
+
return `<div class="code-block"${attr2}>${html}</div>
|
|
513
|
+
`;
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function fenceLanguages(md, content) {
|
|
517
|
+
const langs = /* @__PURE__ */ new Set();
|
|
518
|
+
const walk = (tokens) => {
|
|
519
|
+
for (const token of tokens) {
|
|
520
|
+
if (token.type === "fence") {
|
|
521
|
+
const lang = token.info.trim().split(/\s+/)[0];
|
|
522
|
+
if (lang) langs.add(lang);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
const scratch = {
|
|
527
|
+
post: { slug: "", file: "", data: {}, content },
|
|
528
|
+
lineOffset: 0,
|
|
529
|
+
error() {
|
|
530
|
+
},
|
|
531
|
+
assetUrl: (file) => file,
|
|
532
|
+
toc: [],
|
|
533
|
+
links: [],
|
|
534
|
+
images: [],
|
|
535
|
+
imageCount: 0
|
|
536
|
+
};
|
|
537
|
+
walk(md.parse(content, scratch));
|
|
538
|
+
return langs;
|
|
539
|
+
}
|
|
540
|
+
function createMarkdown(options) {
|
|
541
|
+
const md = (0, import_markdown_it.default)({ html: true, linkify: true, typographer: true });
|
|
542
|
+
directivesPlugin(md, { ...BUILT_IN_DIRECTIVES, ...options.directives });
|
|
543
|
+
headings(md);
|
|
544
|
+
images(md);
|
|
545
|
+
links(md);
|
|
546
|
+
fences(md, options.highlighter);
|
|
547
|
+
options.extend?.(md);
|
|
548
|
+
return md;
|
|
549
|
+
}
|
|
550
|
+
function countWords(content) {
|
|
551
|
+
return content.replace(/^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?^[ \t]*\1[ \t]*$/gm, "").replace(/!\[[^\]]*\]\([^)]*\)/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/<[^>]+>/g, " ").replace(/^:::.*$/gm, "").split(/\s+/).filter((word) => /[\p{L}\p{N}]/u.test(word)).length;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/content.ts
|
|
555
|
+
var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
556
|
+
function resolveOptions(options, vite) {
|
|
557
|
+
return {
|
|
558
|
+
...options,
|
|
559
|
+
dir: import_node_path2.default.resolve(vite.root, options.dir),
|
|
560
|
+
template: import_node_path2.default.resolve(vite.root, options.template),
|
|
561
|
+
base: normalizeBase(options.base ?? "/blog/"),
|
|
562
|
+
siteBase: normalizeBase(vite.base.startsWith("/") ? vite.base : "/"),
|
|
563
|
+
timeZone: resolveTimeZone(options.timeZone),
|
|
564
|
+
locale: options.locale ?? "en-US",
|
|
565
|
+
wordsPerMinute: options.wordsPerMinute ?? 230,
|
|
566
|
+
titleSuffix: options.titleSuffix ?? ""
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function postPath(options, slug) {
|
|
570
|
+
return `${options.base}${slug}/`;
|
|
571
|
+
}
|
|
572
|
+
function readYamlFile(file, issues) {
|
|
573
|
+
if (!(0, import_node_fs2.existsSync)(file)) return null;
|
|
574
|
+
try {
|
|
575
|
+
return toRecord((0, import_yaml2.parse)((0, import_node_fs2.readFileSync)(file, "utf8")));
|
|
576
|
+
} catch (error) {
|
|
577
|
+
issues.push({ file, message: `invalid YAML: ${error.message}` });
|
|
578
|
+
return {};
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
function readTags(options, issues, files) {
|
|
582
|
+
if (options.tags) return options.tags;
|
|
583
|
+
const file = import_node_path2.default.join(options.dir, "tags.yml");
|
|
584
|
+
files.push(file);
|
|
585
|
+
const data = readYamlFile(file, issues);
|
|
586
|
+
if (!data) return null;
|
|
587
|
+
const tags = {};
|
|
588
|
+
for (const [id, value] of Object.entries(data)) {
|
|
589
|
+
const record = toRecord(value);
|
|
590
|
+
tags[id] = {
|
|
591
|
+
name: toText(record.name) || id,
|
|
592
|
+
description: toText(record.description) || void 0
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
return tags;
|
|
596
|
+
}
|
|
597
|
+
function readAuthors(options, issues, files) {
|
|
598
|
+
if (options.authors) return options.authors;
|
|
599
|
+
const file = import_node_path2.default.join(options.dir, "authors.yml");
|
|
600
|
+
files.push(file);
|
|
601
|
+
const data = readYamlFile(file, issues);
|
|
602
|
+
if (!data) return null;
|
|
603
|
+
const authors = {};
|
|
604
|
+
for (const [id, value] of Object.entries(data)) {
|
|
605
|
+
const record = toRecord(value);
|
|
606
|
+
authors[id] = { name: toText(record.name) || id, url: toText(record.url) || void 0 };
|
|
607
|
+
}
|
|
608
|
+
return authors;
|
|
609
|
+
}
|
|
610
|
+
function findPosts(dir, issues) {
|
|
611
|
+
const postsDir = import_node_path2.default.join(dir, "posts");
|
|
612
|
+
if (!(0, import_node_fs2.existsSync)(postsDir)) {
|
|
613
|
+
issues.push({ file: postsDir, message: "the blog's posts folder doesn't exist" });
|
|
614
|
+
return [];
|
|
615
|
+
}
|
|
616
|
+
const found = /* @__PURE__ */ new Map();
|
|
617
|
+
for (const entry of (0, import_node_fs2.readdirSync)(postsDir, { withFileTypes: true })) {
|
|
618
|
+
if (entry.name.startsWith(".") || entry.name.startsWith("_")) continue;
|
|
619
|
+
let slug;
|
|
620
|
+
let file;
|
|
621
|
+
if (entry.isDirectory()) {
|
|
622
|
+
file = import_node_path2.default.join(postsDir, entry.name, "index.md");
|
|
623
|
+
if (!(0, import_node_fs2.existsSync)(file)) continue;
|
|
624
|
+
slug = entry.name;
|
|
625
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
626
|
+
file = import_node_path2.default.join(postsDir, entry.name);
|
|
627
|
+
slug = entry.name.slice(0, -3);
|
|
628
|
+
} else continue;
|
|
629
|
+
if (!SLUG.test(slug)) {
|
|
630
|
+
issues.push({
|
|
631
|
+
file,
|
|
632
|
+
message: `"${slug}" isn't a valid address: use lowercase letters, numbers and hyphens`
|
|
633
|
+
});
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
const other = found.get(slug);
|
|
637
|
+
if (other) {
|
|
638
|
+
issues.push({ file, message: `the address /${slug}/ is already used by ${other}` });
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
found.set(slug, file);
|
|
642
|
+
}
|
|
643
|
+
return [...found].map(([slug, file]) => ({ slug, file }));
|
|
644
|
+
}
|
|
645
|
+
function createLoader(options, assetUrl) {
|
|
646
|
+
let highlighter;
|
|
647
|
+
let md;
|
|
648
|
+
async function setup() {
|
|
649
|
+
highlighter ??= options.highlight === false ? Promise.resolve(null) : createCodeHighlighter({
|
|
650
|
+
themes: options.highlight?.themes ?? { light: "github-light", dark: "github-dark" },
|
|
651
|
+
classPrefix: options.highlight?.classPrefix ?? "sk-"
|
|
652
|
+
});
|
|
653
|
+
const resolved = await highlighter;
|
|
654
|
+
md ??= createMarkdown({
|
|
655
|
+
directives: options.directives ?? {},
|
|
656
|
+
highlighter: resolved,
|
|
657
|
+
extend: options.markdown
|
|
658
|
+
});
|
|
659
|
+
return { highlighter: resolved, md };
|
|
660
|
+
}
|
|
661
|
+
return async function load() {
|
|
662
|
+
const { highlighter: highlighter2, md: md2 } = await setup();
|
|
663
|
+
const issues = [];
|
|
664
|
+
const files = [options.template];
|
|
665
|
+
const tags = readTags(options, issues, files);
|
|
666
|
+
const authors = readAuthors(options, issues, files);
|
|
667
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
668
|
+
const limits = {
|
|
669
|
+
title: 70,
|
|
670
|
+
description: 160,
|
|
671
|
+
minTags: 0,
|
|
672
|
+
maxTags: Infinity,
|
|
673
|
+
...options.limits
|
|
674
|
+
};
|
|
675
|
+
const sources = [];
|
|
676
|
+
for (const { slug, file } of findPosts(options.dir, issues)) {
|
|
677
|
+
files.push(file);
|
|
678
|
+
try {
|
|
679
|
+
const { data, content } = readFrontmatter((0, import_node_fs2.readFileSync)(file, "utf8"));
|
|
680
|
+
sources.push({ slug, file, data, content });
|
|
681
|
+
} catch (error) {
|
|
682
|
+
issues.push({ file, message: `invalid front matter: ${error.message}` });
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
const drafts = /* @__PURE__ */ new Map();
|
|
686
|
+
const included = [];
|
|
687
|
+
for (const source of sources) {
|
|
688
|
+
const date = parsePostDate(source.data.date, options.timeZone);
|
|
689
|
+
const draft = source.data.draft === true;
|
|
690
|
+
const scheduled = !!date && date.date > now;
|
|
691
|
+
if (!options.preview && (draft || scheduled)) {
|
|
692
|
+
drafts.set(source.slug, draft ? "draft" : "scheduled");
|
|
693
|
+
} else included.push(source);
|
|
694
|
+
}
|
|
695
|
+
if (highlighter2) {
|
|
696
|
+
const langs = /* @__PURE__ */ new Set();
|
|
697
|
+
for (const source of included)
|
|
698
|
+
for (const lang of fenceLanguages(md2, source.content)) langs.add(lang);
|
|
699
|
+
const unknown = await highlighter2.load(langs);
|
|
700
|
+
if (unknown.length) {
|
|
701
|
+
console.warn(
|
|
702
|
+
`[vite-plugin-blog] no highlighting for: ${unknown.join(", ")}. Shown as plain text.`
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
const posts = [];
|
|
707
|
+
const linksByPost = /* @__PURE__ */ new Map();
|
|
708
|
+
for (const source of included) {
|
|
709
|
+
const problems = [];
|
|
710
|
+
const report = (message) => problems.push(message);
|
|
711
|
+
const { data, slug, file } = source;
|
|
712
|
+
const title = toText(data.title);
|
|
713
|
+
if (!title) report("title is missing");
|
|
714
|
+
else if (title.length > limits.title)
|
|
715
|
+
report(`title is ${title.length} characters; the limit is ${limits.title}`);
|
|
716
|
+
const description = toText(data.description);
|
|
717
|
+
if (!description) report("description is missing");
|
|
718
|
+
else if (description.length > limits.description)
|
|
719
|
+
report(
|
|
720
|
+
`description is ${description.length} characters; the limit is ${limits.description}`
|
|
721
|
+
);
|
|
722
|
+
const date = parsePostDate(data.date, options.timeZone);
|
|
723
|
+
if (!date)
|
|
724
|
+
report(
|
|
725
|
+
data.date === void 0 ? "date is missing" : `date "${String(data.date)}" isn't a date (use 2026-12-02)`
|
|
726
|
+
);
|
|
727
|
+
const updated = data.updated === void 0 ? null : parsePostDate(data.updated, options.timeZone);
|
|
728
|
+
if (data.updated !== void 0 && !updated)
|
|
729
|
+
report(`updated "${String(data.updated)}" isn't a date`);
|
|
730
|
+
if (date && updated && updated.date < date.date) report("updated is before date");
|
|
731
|
+
const postTags = toStringList(data.tags);
|
|
732
|
+
if (postTags.length < limits.minTags)
|
|
733
|
+
report(`needs at least ${limits.minTags} tag${limits.minTags === 1 ? "" : "s"}`);
|
|
734
|
+
if (postTags.length > limits.maxTags)
|
|
735
|
+
report(`has ${postTags.length} tags; the limit is ${limits.maxTags}`);
|
|
736
|
+
if (tags) {
|
|
737
|
+
for (const tag of postTags)
|
|
738
|
+
if (!Object.hasOwn(tags, tag)) report(`tag "${tag}" isn't in tags.yml`);
|
|
739
|
+
}
|
|
740
|
+
const authorIds = toStringList(data.authors ?? data.author);
|
|
741
|
+
const postAuthors = [];
|
|
742
|
+
for (const id of authorIds) {
|
|
743
|
+
if (authors && !Object.hasOwn(authors, id)) report(`author "${id}" isn't in authors.yml`);
|
|
744
|
+
else postAuthors.push(authors?.[id] ?? { name: id });
|
|
745
|
+
}
|
|
746
|
+
let cover;
|
|
747
|
+
const coverValue = toText(data.cover);
|
|
748
|
+
if (coverValue) {
|
|
749
|
+
const coverFile = import_node_path2.default.resolve(import_node_path2.default.dirname(file), coverValue);
|
|
750
|
+
if (/^[a-z]+:|^\//i.test(coverValue)) cover = coverValue;
|
|
751
|
+
else if (!(0, import_node_fs2.existsSync)(coverFile)) report(`cover "${coverValue}" doesn't exist`);
|
|
752
|
+
else {
|
|
753
|
+
cover = assetUrl(coverFile, slug);
|
|
754
|
+
files.push(coverFile);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
const raw = (0, import_node_fs2.readFileSync)(file, "utf8").replace(/^\uFEFF/, "");
|
|
758
|
+
const env = {
|
|
759
|
+
post: source,
|
|
760
|
+
lineOffset: raw.slice(0, raw.length - source.content.length).split("\n").length - 1,
|
|
761
|
+
error: report,
|
|
762
|
+
assetUrl: (asset) => assetUrl(asset, slug),
|
|
763
|
+
toc: [],
|
|
764
|
+
links: [],
|
|
765
|
+
images: [],
|
|
766
|
+
imageCount: 0
|
|
767
|
+
};
|
|
768
|
+
let html = "";
|
|
769
|
+
try {
|
|
770
|
+
html = md2.render(source.content, env);
|
|
771
|
+
} catch (error) {
|
|
772
|
+
report(`couldn't render: ${error.message}`);
|
|
773
|
+
}
|
|
774
|
+
files.push(...env.images);
|
|
775
|
+
const words = countWords(source.content);
|
|
776
|
+
const sitePath = postPath(options, slug);
|
|
777
|
+
const post = {
|
|
778
|
+
slug,
|
|
779
|
+
url: joinUrl(options.siteBase, sitePath),
|
|
780
|
+
canonical: options.site ? joinUrl(options.site, joinUrl(options.siteBase, sitePath)) : void 0,
|
|
781
|
+
file,
|
|
782
|
+
title,
|
|
783
|
+
description,
|
|
784
|
+
date: date?.date ?? /* @__PURE__ */ new Date(0),
|
|
785
|
+
dateHasTime: date?.hasTime ?? false,
|
|
786
|
+
updated: updated?.date,
|
|
787
|
+
tags: postTags,
|
|
788
|
+
authors: postAuthors,
|
|
789
|
+
draft: data.draft === true,
|
|
790
|
+
scheduled: !!date && date.date > now,
|
|
791
|
+
featured: data.featured === true,
|
|
792
|
+
series: toText(data.series) || void 0,
|
|
793
|
+
cover,
|
|
794
|
+
data,
|
|
795
|
+
html,
|
|
796
|
+
toc: env.toc,
|
|
797
|
+
readingMinutes: Math.max(1, Math.ceil(words / options.wordsPerMinute)),
|
|
798
|
+
words
|
|
799
|
+
};
|
|
800
|
+
for (const message of options.validate?.(post) ?? []) report(message);
|
|
801
|
+
for (const message of problems) issues.push({ file, message });
|
|
802
|
+
linksByPost.set(post, env.links);
|
|
803
|
+
posts.push(post);
|
|
804
|
+
}
|
|
805
|
+
const published = new Set(posts.map((post) => post.slug));
|
|
806
|
+
const usedTags2 = new Set(posts.flatMap((post) => post.tags));
|
|
807
|
+
for (const [post, links2] of linksByPost) {
|
|
808
|
+
for (const { href, line } of links2) {
|
|
809
|
+
const where = line ? `line ${line}: ` : "";
|
|
810
|
+
const pathname = href.split(/[?#]/)[0];
|
|
811
|
+
if (pathname.startsWith(options.base)) {
|
|
812
|
+
const rest = pathname.slice(options.base.length).replace(/(?:\/index\.html|\/)$/, "");
|
|
813
|
+
if (!rest) continue;
|
|
814
|
+
const tag = /^tag\/([^/]+)$/.exec(rest)?.[1];
|
|
815
|
+
if (tag) {
|
|
816
|
+
if (options.tagPages !== false && usedTags2.has(tag)) continue;
|
|
817
|
+
issues.push({
|
|
818
|
+
file: post.file,
|
|
819
|
+
message: `${where}link to ${href} goes nowhere: no published post has the tag "${tag}"`
|
|
820
|
+
});
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
823
|
+
if (rest.includes("/")) {
|
|
824
|
+
issues.push({ file: post.file, message: `${where}link to ${href} goes nowhere` });
|
|
825
|
+
continue;
|
|
826
|
+
}
|
|
827
|
+
if (published.has(rest)) continue;
|
|
828
|
+
const state = drafts.get(rest);
|
|
829
|
+
issues.push({
|
|
830
|
+
file: post.file,
|
|
831
|
+
message: state ? `${where}link to ${href} goes to a ${state} post, which isn't published yet` : `${where}link to ${href} goes nowhere: there's no post "${rest}"`
|
|
832
|
+
});
|
|
833
|
+
} else if (options.isKnownPath && !options.isKnownPath(pathname)) {
|
|
834
|
+
issues.push({ file: post.file, message: `${where}link to ${href} goes nowhere` });
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
posts.sort((a, b) => b.date.getTime() - a.date.getTime() || a.slug.localeCompare(b.slug));
|
|
839
|
+
return {
|
|
840
|
+
posts,
|
|
841
|
+
issues,
|
|
842
|
+
css: highlighter2?.css() ?? "",
|
|
843
|
+
tags: tags ?? {},
|
|
844
|
+
files: [...new Set(files)]
|
|
845
|
+
};
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function isBlogFile(options, file) {
|
|
849
|
+
const relative = import_node_path2.default.relative(options.dir, file);
|
|
850
|
+
return file === options.template || !relative.startsWith("..") && !import_node_path2.default.isAbsolute(relative);
|
|
851
|
+
}
|
|
852
|
+
function formatIssues(issues, root) {
|
|
853
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
854
|
+
for (const { file, message } of issues) {
|
|
855
|
+
const name = import_node_path2.default.relative(root, file) || file;
|
|
856
|
+
byFile.set(name, [...byFile.get(name) ?? [], message]);
|
|
857
|
+
}
|
|
858
|
+
const lines = [
|
|
859
|
+
`[vite-plugin-blog] ${issues.length} problem${issues.length === 1 ? "" : "s"} in the blog:`
|
|
860
|
+
];
|
|
861
|
+
for (const [file, messages] of byFile) {
|
|
862
|
+
lines.push(` ${file}`);
|
|
863
|
+
for (const message of messages) lines.push(` - ${message}`);
|
|
864
|
+
}
|
|
865
|
+
return lines.join("\n");
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// src/pages.ts
|
|
869
|
+
var HEAD_MARKER = "<!--blog:head-->";
|
|
870
|
+
var CONTENT_MARKER = "<!--blog:content-->";
|
|
871
|
+
function meta(attribute, key, value) {
|
|
872
|
+
return value ? `<meta ${attribute}="${key}" content="${escapeHtml(value)}">` : "";
|
|
873
|
+
}
|
|
874
|
+
function renderToc(toc) {
|
|
875
|
+
if (toc.length < 2) return "";
|
|
876
|
+
const items = toc.map(
|
|
877
|
+
(entry) => `<li class="toc-${entry.level}"><a href="#${escapeHtml(entry.id)}">${escapeHtml(entry.text)}</a></li>`
|
|
878
|
+
).join("");
|
|
879
|
+
return `<nav class="toc" aria-label="On this page"><p class="toc-title">On this page</p><ol>${items}</ol></nav>`;
|
|
880
|
+
}
|
|
881
|
+
function usedTags(content) {
|
|
882
|
+
const used = new Set(content.posts.flatMap((post) => post.tags));
|
|
883
|
+
const known = Object.keys(content.tags).filter((tag) => used.has(tag));
|
|
884
|
+
const others = [...used].filter((tag) => !Object.hasOwn(content.tags, tag)).sort();
|
|
885
|
+
return [...known, ...others];
|
|
886
|
+
}
|
|
887
|
+
function listPath(options, tag) {
|
|
888
|
+
return tag ? `${options.base}tag/${tag}/` : options.base;
|
|
889
|
+
}
|
|
890
|
+
function listPages(options, content) {
|
|
891
|
+
const page = (sitePath) => ({
|
|
892
|
+
url: joinUrl(options.siteBase, sitePath),
|
|
893
|
+
canonical: options.site ? joinUrl(options.site, joinUrl(options.siteBase, sitePath)) : void 0
|
|
894
|
+
});
|
|
895
|
+
const pages = [
|
|
896
|
+
{
|
|
897
|
+
kind: "index",
|
|
898
|
+
...page(listPath(options)),
|
|
899
|
+
title: options.index?.title ?? "Blog",
|
|
900
|
+
description: options.index?.description ?? "",
|
|
901
|
+
posts: content.posts
|
|
902
|
+
}
|
|
903
|
+
];
|
|
904
|
+
if (options.tagPages === false) return pages;
|
|
905
|
+
for (const tag of usedTags(content)) {
|
|
906
|
+
const info = content.tags[tag];
|
|
907
|
+
pages.push({
|
|
908
|
+
kind: "tag",
|
|
909
|
+
...page(listPath(options, tag)),
|
|
910
|
+
title: info?.name ?? tag,
|
|
911
|
+
description: info?.description ?? "",
|
|
912
|
+
tag,
|
|
913
|
+
posts: content.posts.filter((post) => post.tags.includes(tag))
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
return pages;
|
|
917
|
+
}
|
|
918
|
+
function createHelpers(options, content) {
|
|
919
|
+
const display = {
|
|
920
|
+
locale: options.locale,
|
|
921
|
+
timeZone: options.timeZone,
|
|
922
|
+
dateFormat: { year: "numeric", month: "long", day: "numeric" },
|
|
923
|
+
timeFormat: { hour: "numeric", minute: "2-digit", timeZoneName: "short" },
|
|
924
|
+
dateTime: "{date} at {time}"
|
|
925
|
+
};
|
|
926
|
+
const formatDate = (date, hasTime = false) => formatPostDate({ date, hasTime }, display);
|
|
927
|
+
const dateAttribute = (date, hasTime = false) => toDateTimeAttribute({ date, hasTime }, options.timeZone);
|
|
928
|
+
const tags = usedTags(content);
|
|
929
|
+
const indexUrl = joinUrl(options.siteBase, listPath(options));
|
|
930
|
+
const tagUrl = (tag) => joinUrl(options.siteBase, listPath(options, tag));
|
|
931
|
+
const tagItem = (tag) => {
|
|
932
|
+
const name = escapeHtml(content.tags[tag]?.name ?? tag);
|
|
933
|
+
return options.tagPages === false ? `<li class="tag">${name}</li>` : `<li class="tag"><a href="${escapeHtml(tagUrl(tag))}">${name}</a></li>`;
|
|
934
|
+
};
|
|
935
|
+
const renderHead = (post) => [
|
|
936
|
+
`<title>${escapeHtml(post.title + options.titleSuffix)}</title>`,
|
|
937
|
+
meta("name", "description", post.description),
|
|
938
|
+
post.draft || post.scheduled ? '<meta name="robots" content="noindex">' : "",
|
|
939
|
+
post.canonical ? `<link rel="canonical" href="${escapeHtml(post.canonical)}">` : "",
|
|
940
|
+
meta("property", "og:type", "article"),
|
|
941
|
+
meta("property", "og:title", post.title),
|
|
942
|
+
meta("property", "og:description", post.description),
|
|
943
|
+
meta("property", "og:url", post.canonical),
|
|
944
|
+
meta("property", "article:published_time", post.date.toISOString()),
|
|
945
|
+
meta("property", "article:modified_time", post.updated?.toISOString()),
|
|
946
|
+
...post.tags.map((tag) => meta("property", "article:tag", content.tags[tag]?.name ?? tag))
|
|
947
|
+
].filter(Boolean).join("\n ");
|
|
948
|
+
const renderArticle = (post) => {
|
|
949
|
+
const tags2 = post.tags.map(tagItem).join("");
|
|
950
|
+
const updated = post.updated ? ` \xB7 Updated <time datetime="${dateAttribute(post.updated)}">${formatDate(post.updated)}</time>` : "";
|
|
951
|
+
return [
|
|
952
|
+
'<article class="post">',
|
|
953
|
+
'<header class="post-header">',
|
|
954
|
+
`<h1>${escapeHtml(post.title)}</h1>`,
|
|
955
|
+
`<p class="post-description">${escapeHtml(post.description)}</p>`,
|
|
956
|
+
`<p class="post-meta"><time datetime="${dateAttribute(post.date, post.dateHasTime)}">${formatDate(post.date, post.dateHasTime)}</time>${updated} \xB7 ${post.readingMinutes} min read</p>`,
|
|
957
|
+
tags2 ? `<ul class="post-tags">${tags2}</ul>` : "",
|
|
958
|
+
"</header>",
|
|
959
|
+
renderToc(post.toc),
|
|
960
|
+
`<div class="prose" data-pagefind-body>
|
|
961
|
+
${post.html}</div>`,
|
|
962
|
+
"</article>"
|
|
963
|
+
].filter(Boolean).join("\n");
|
|
964
|
+
};
|
|
965
|
+
const indexTitle = options.index?.title ?? "Blog";
|
|
966
|
+
const renderListHead = (page) => {
|
|
967
|
+
const title = page.kind === "index" ? page.title : `${page.title} \xB7 ${indexTitle}`;
|
|
968
|
+
return [
|
|
969
|
+
`<title>${escapeHtml(title + options.titleSuffix)}</title>`,
|
|
970
|
+
meta("name", "description", page.description),
|
|
971
|
+
page.canonical ? `<link rel="canonical" href="${escapeHtml(page.canonical)}">` : "",
|
|
972
|
+
meta("property", "og:type", "website"),
|
|
973
|
+
meta("property", "og:title", title),
|
|
974
|
+
meta("property", "og:description", page.description),
|
|
975
|
+
meta("property", "og:url", page.canonical)
|
|
976
|
+
].filter(Boolean).join("\n ");
|
|
977
|
+
};
|
|
978
|
+
const renderList = (page) => {
|
|
979
|
+
const items = page.posts.map((post) => {
|
|
980
|
+
const postTags = post.tags.map(tagItem).join("");
|
|
981
|
+
return [
|
|
982
|
+
'<li class="post-item">',
|
|
983
|
+
`<h2><a href="${escapeHtml(post.url)}">${escapeHtml(post.title)}</a></h2>`,
|
|
984
|
+
`<p class="post-meta"><time datetime="${dateAttribute(post.date, post.dateHasTime)}">${formatDate(post.date, post.dateHasTime)}</time> \xB7 ${post.readingMinutes} min read</p>`,
|
|
985
|
+
`<p class="post-description">${escapeHtml(post.description)}</p>`,
|
|
986
|
+
postTags ? `<ul class="post-tags">${postTags}</ul>` : "",
|
|
987
|
+
"</li>"
|
|
988
|
+
].filter(Boolean).join("");
|
|
989
|
+
}).join("\n");
|
|
990
|
+
const tagLinks = options.tagPages === false ? "" : tags.map((tag) => {
|
|
991
|
+
const current = page.tag === tag ? ' aria-current="page"' : "";
|
|
992
|
+
return `<li><a href="${escapeHtml(tagUrl(tag))}"${current}>${escapeHtml(content.tags[tag]?.name ?? tag)}</a></li>`;
|
|
993
|
+
}).join("");
|
|
994
|
+
return [
|
|
995
|
+
`<section class="post-list" aria-labelledby="post-list-title">`,
|
|
996
|
+
`<h1 id="post-list-title">${escapeHtml(page.title)}</h1>`,
|
|
997
|
+
page.description ? `<p class="post-list-description">${escapeHtml(page.description)}</p>` : "",
|
|
998
|
+
tagLinks ? `<nav class="post-list-tags" aria-label="Tags"><ul>${tagLinks}</ul></nav>` : "",
|
|
999
|
+
items ? `<ul class="post-items">
|
|
1000
|
+
${items}
|
|
1001
|
+
</ul>` : '<p class="post-list-empty">No posts yet.</p>',
|
|
1002
|
+
"</section>"
|
|
1003
|
+
].filter(Boolean).join("\n");
|
|
1004
|
+
};
|
|
1005
|
+
return {
|
|
1006
|
+
indexUrl,
|
|
1007
|
+
tagUrl,
|
|
1008
|
+
usedTags: tags,
|
|
1009
|
+
renderListHead,
|
|
1010
|
+
renderList,
|
|
1011
|
+
escapeHtml,
|
|
1012
|
+
formatDate,
|
|
1013
|
+
dateAttribute,
|
|
1014
|
+
renderToc,
|
|
1015
|
+
renderHead,
|
|
1016
|
+
renderArticle,
|
|
1017
|
+
tags: content.tags,
|
|
1018
|
+
posts: content.posts
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
function fillTemplate(template, head, article) {
|
|
1022
|
+
const withHead = template.includes(HEAD_MARKER) ? template.replace(HEAD_MARKER, () => head) : template.replace(/<\/head>/i, () => ` ${head}
|
|
1023
|
+
</head>`);
|
|
1024
|
+
return withHead.replace(CONTENT_MARKER, () => article);
|
|
1025
|
+
}
|
|
1026
|
+
function renderPostPage(template, post, options, helpers) {
|
|
1027
|
+
const head = options.render?.head?.(post, helpers) ?? helpers.renderHead(post);
|
|
1028
|
+
const article = options.render?.article?.(post, helpers) ?? helpers.renderArticle(post);
|
|
1029
|
+
return fillTemplate(template, head, article);
|
|
1030
|
+
}
|
|
1031
|
+
function renderListPage(template, page, options, helpers) {
|
|
1032
|
+
const head = options.render?.listHead?.(page, helpers) ?? helpers.renderListHead(page);
|
|
1033
|
+
const body = options.render?.list?.(page, helpers) ?? helpers.renderList(page);
|
|
1034
|
+
return fillTemplate(template, head, body);
|
|
1035
|
+
}
|
|
1036
|
+
function postSummaries(posts) {
|
|
1037
|
+
return posts.map((post) => ({
|
|
1038
|
+
slug: post.slug,
|
|
1039
|
+
url: post.url,
|
|
1040
|
+
title: post.title,
|
|
1041
|
+
description: post.description,
|
|
1042
|
+
date: post.date.toISOString(),
|
|
1043
|
+
updated: post.updated?.toISOString(),
|
|
1044
|
+
tags: post.tags,
|
|
1045
|
+
authors: post.authors,
|
|
1046
|
+
featured: post.featured,
|
|
1047
|
+
series: post.series,
|
|
1048
|
+
readingMinutes: post.readingMinutes,
|
|
1049
|
+
data: post.data
|
|
1050
|
+
}));
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// src/plugin.ts
|
|
1054
|
+
var POSTS_ID = "virtual:blog/posts";
|
|
1055
|
+
var CSS_ID = "virtual:blog/code.css";
|
|
1056
|
+
var RESOLVED_POSTS_ID = "\0virtual:blog/posts";
|
|
1057
|
+
var RESOLVED_CSS_ID = "/__vite-plugin-blog/code.css";
|
|
1058
|
+
function toPosix(file) {
|
|
1059
|
+
return file.split(import_node_path3.default.sep).join("/");
|
|
1060
|
+
}
|
|
1061
|
+
function addInputs(input, pages) {
|
|
1062
|
+
if (!input) return pages;
|
|
1063
|
+
if (typeof input === "string") return { index: input, ...pages };
|
|
1064
|
+
if (Array.isArray(input)) return [...input, ...Object.values(pages)];
|
|
1065
|
+
return { ...input, ...pages };
|
|
1066
|
+
}
|
|
1067
|
+
function blog(userOptions) {
|
|
1068
|
+
let config;
|
|
1069
|
+
let options;
|
|
1070
|
+
let load;
|
|
1071
|
+
let content;
|
|
1072
|
+
const pageIds = /* @__PURE__ */ new Map();
|
|
1073
|
+
const fileFor = (sitePath) => import_node_path3.default.join(config.root, sitePath.slice(1), "index.html");
|
|
1074
|
+
const pageFile = (slug) => fileFor(postPath(options, slug));
|
|
1075
|
+
const allPages = () => {
|
|
1076
|
+
const pages = /* @__PURE__ */ new Map();
|
|
1077
|
+
for (const page of listPages(options, content)) {
|
|
1078
|
+
pages.set(page.url.slice(options.siteBase.length - 1), { kind: "list", page });
|
|
1079
|
+
}
|
|
1080
|
+
for (const post of content.posts)
|
|
1081
|
+
pages.set(postPath(options, post.slug), { kind: "post", post });
|
|
1082
|
+
return pages;
|
|
1083
|
+
};
|
|
1084
|
+
const assetUrl = (file, slug) => config.command === "serve" ? `/@fs/${toPosix(file).replace(/^\/+/, "")}` : toPosix(import_node_path3.default.relative(import_node_path3.default.dirname(pageFile(slug)), file));
|
|
1085
|
+
const readTemplate = () => {
|
|
1086
|
+
const template = (0, import_node_fs3.readFileSync)(options.template, "utf8");
|
|
1087
|
+
if (!template.includes(CONTENT_MARKER))
|
|
1088
|
+
throw new Error(
|
|
1089
|
+
`[vite-plugin-blog] ${import_node_path3.default.relative(config.root, options.template)} has no ${CONTENT_MARKER} marker`
|
|
1090
|
+
);
|
|
1091
|
+
return template;
|
|
1092
|
+
};
|
|
1093
|
+
const renderPage = (page) => {
|
|
1094
|
+
const helpers = createHelpers(options, content);
|
|
1095
|
+
return page.kind === "post" ? renderPostPage(readTemplate(), page.post, options, helpers) : renderListPage(readTemplate(), page.page, options, helpers);
|
|
1096
|
+
};
|
|
1097
|
+
return {
|
|
1098
|
+
name: "vite-plugin-blog",
|
|
1099
|
+
enforce: "pre",
|
|
1100
|
+
async configResolved(resolved) {
|
|
1101
|
+
config = resolved;
|
|
1102
|
+
options = resolveOptions(userOptions, { root: config.root, base: config.base });
|
|
1103
|
+
if (config.command === "serve") config.server.fs.allow.push(options.dir);
|
|
1104
|
+
load = createLoader(options, assetUrl);
|
|
1105
|
+
content = await load();
|
|
1106
|
+
if (content.issues.length) {
|
|
1107
|
+
const message = formatIssues(content.issues, config.root);
|
|
1108
|
+
if (config.command === "build") throw new Error(message);
|
|
1109
|
+
config.logger.error(message);
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
options(inputOptions) {
|
|
1113
|
+
if (config.command !== "build") return;
|
|
1114
|
+
pageIds.clear();
|
|
1115
|
+
const pages = {};
|
|
1116
|
+
for (const [sitePath, page] of allPages()) {
|
|
1117
|
+
const id = fileFor(sitePath);
|
|
1118
|
+
pageIds.set(id, page);
|
|
1119
|
+
const rest = sitePath.slice(options.base.length).replace(/\/$/, "");
|
|
1120
|
+
pages[rest ? `blog-${rest.replace(/^tag\//, "tag__")}` : "blog"] = id;
|
|
1121
|
+
}
|
|
1122
|
+
return { ...inputOptions, input: addInputs(inputOptions.input, pages) };
|
|
1123
|
+
},
|
|
1124
|
+
resolveId(id) {
|
|
1125
|
+
if (id === POSTS_ID) return RESOLVED_POSTS_ID;
|
|
1126
|
+
if (id === CSS_ID) return RESOLVED_CSS_ID;
|
|
1127
|
+
if (pageIds.has(id)) return id;
|
|
1128
|
+
return null;
|
|
1129
|
+
},
|
|
1130
|
+
load(id) {
|
|
1131
|
+
if (id === RESOLVED_POSTS_ID)
|
|
1132
|
+
return `export const posts = ${JSON.stringify(postSummaries(content.posts))};
|
|
1133
|
+
export default posts;
|
|
1134
|
+
`;
|
|
1135
|
+
if (id === RESOLVED_CSS_ID) return content.css;
|
|
1136
|
+
const page = pageIds.get(id);
|
|
1137
|
+
if (page) return renderPage(page);
|
|
1138
|
+
return null;
|
|
1139
|
+
},
|
|
1140
|
+
configureServer(server) {
|
|
1141
|
+
server.watcher.add([options.dir, options.template]);
|
|
1142
|
+
const reload = async (file) => {
|
|
1143
|
+
if (!isBlogFile(options, file) && !content.files.includes(file)) return;
|
|
1144
|
+
content = await load();
|
|
1145
|
+
for (const id of [RESOLVED_POSTS_ID, RESOLVED_CSS_ID]) {
|
|
1146
|
+
const module2 = server.moduleGraph.getModuleById(id);
|
|
1147
|
+
if (module2) server.moduleGraph.invalidateModule(module2);
|
|
1148
|
+
}
|
|
1149
|
+
if (content.issues.length) {
|
|
1150
|
+
const message = formatIssues(content.issues, config.root);
|
|
1151
|
+
config.logger.error(message, { timestamp: true });
|
|
1152
|
+
server.ws.send({ type: "error", err: { message, stack: "" } });
|
|
1153
|
+
} else {
|
|
1154
|
+
server.ws.send({ type: "full-reload" });
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
server.watcher.on("add", reload);
|
|
1158
|
+
server.watcher.on("change", reload);
|
|
1159
|
+
server.watcher.on("unlink", reload);
|
|
1160
|
+
server.middlewares.use(async (req, res, next) => {
|
|
1161
|
+
try {
|
|
1162
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
1163
|
+
const siteBase = options.siteBase.replace(/\/$/, "");
|
|
1164
|
+
if (!url.pathname.startsWith(siteBase)) return next();
|
|
1165
|
+
const sitePath = url.pathname.slice(siteBase.length).replace(/\/index\.html$/, "/");
|
|
1166
|
+
if (!sitePath.startsWith(options.base.replace(/\/$/, ""))) return next();
|
|
1167
|
+
const pages = allPages();
|
|
1168
|
+
const page = pages.get(sitePath);
|
|
1169
|
+
if (!page) {
|
|
1170
|
+
if (!sitePath.endsWith("/") && pages.has(`${sitePath}/`)) {
|
|
1171
|
+
res.statusCode = 301;
|
|
1172
|
+
res.setHeader("Location", `${siteBase}${sitePath}/${url.search}`);
|
|
1173
|
+
return res.end();
|
|
1174
|
+
}
|
|
1175
|
+
return next();
|
|
1176
|
+
}
|
|
1177
|
+
const html = await server.transformIndexHtml(
|
|
1178
|
+
`${sitePath}index.html`,
|
|
1179
|
+
renderPage(page),
|
|
1180
|
+
req.originalUrl
|
|
1181
|
+
);
|
|
1182
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
1183
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
1184
|
+
res.end(html);
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
next(error);
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1193
|
+
0 && (module.exports = {
|
|
1194
|
+
BUILT_IN_DIRECTIVES,
|
|
1195
|
+
blog,
|
|
1196
|
+
escapeHtml,
|
|
1197
|
+
slugify
|
|
1198
|
+
});
|
|
1199
|
+
//# sourceMappingURL=index.cjs.map
|