@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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/content.ts","../src/dates.ts","../src/highlight.ts","../src/util.ts","../src/markdown.ts","../src/directives.ts","../src/pages.ts"],"sourcesContent":["export { blog, blog as default } from \"./plugin.js\";\nexport { BUILT_IN_DIRECTIVES } from \"./directives.js\";\nexport { escapeHtml, slugify } from \"./util.js\";\nexport type {\n AuthorInfo,\n BlogIssue,\n BlogOptions,\n Directive,\n DirectiveContext,\n ListPage,\n Post,\n PostSource,\n RenderHelpers,\n TagInfo,\n TocEntry,\n} from \"./types.js\";\n","import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig, ViteDevServer } from \"vite\";\nimport {\n createLoader,\n formatIssues,\n isBlogFile,\n postPath,\n resolveOptions,\n type BlogContent,\n type ResolvedBlogOptions,\n} from \"./content.js\";\nimport {\n CONTENT_MARKER,\n createHelpers,\n listPages,\n postSummaries,\n renderListPage,\n renderPostPage,\n} from \"./pages.js\";\nimport type { BlogOptions, ListPage, Post } from \"./types.js\";\n\nconst POSTS_ID = \"virtual:blog/posts\";\nconst CSS_ID = \"virtual:blog/code.css\";\n// Not `\\0`-prefixed: Vite's CSS plugin only handles ids that look like CSS files.\nconst RESOLVED_POSTS_ID = \"\\0virtual:blog/posts\";\nconst RESOLVED_CSS_ID = \"/__vite-plugin-blog/code.css\";\n\ntype InputOption = string | string[] | Record<string, string>;\n\n/** A page the blog writes: a post, or the index or a tag page. */\ntype BlogPage = { kind: \"post\"; post: Post } | { kind: \"list\"; page: ListPage };\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join(\"/\");\n}\n\n/** Adds the post pages to whatever input the config already has. */\nfunction addInputs(input: InputOption | undefined, pages: Record<string, string>): InputOption {\n if (!input) return pages;\n if (typeof input === \"string\") return { index: input, ...pages };\n if (Array.isArray(input)) return [...input, ...Object.values(pages)];\n return { ...input, ...pages };\n}\n\n/**\n * A static Markdown blog for a Vite site. Each post becomes an HTML page,\n * built from the site's own page shell, so the site's scripts, styles and\n * `transformIndexHtml` plugins apply to posts like to any other page.\n */\nexport function blog(userOptions: BlogOptions): Plugin {\n let config: ResolvedConfig;\n let options: ResolvedBlogOptions;\n let load: () => Promise<BlogContent>;\n let content: BlogContent;\n /** Absolute HTML ids in the build, and their pages. */\n const pageIds = new Map<string, BlogPage>();\n\n /** Where a page sits in the project: `/blog/vpn-leaks/` is `<root>/blog/vpn-leaks/index.html`. */\n const fileFor = (sitePath: string) => path.join(config.root, sitePath.slice(1), \"index.html\");\n const pageFile = (slug: string) => fileFor(postPath(options, slug));\n\n /** Every page, by its path on the site without Vite's base: `/blog/`, `/blog/tag/dns/`, `/blog/vpn-leaks/`. */\n const allPages = () => {\n const pages = new Map<string, BlogPage>();\n for (const page of listPages(options, content)) {\n pages.set(page.url.slice(options.siteBase.length - 1), { kind: \"list\", page });\n }\n for (const post of content.posts)\n pages.set(postPath(options, post.slug), { kind: \"post\", post });\n return pages;\n };\n\n /**\n * A local file's URL in a post. The build resolves it from the page's own\n * location, so Vite hashes and copies it. Dev serves it straight from disk.\n */\n const assetUrl = (file: string, slug: string) =>\n config.command === \"serve\"\n ? `/@fs/${toPosix(file).replace(/^\\/+/, \"\")}`\n : toPosix(path.relative(path.dirname(pageFile(slug)), file));\n\n const readTemplate = () => {\n const template = readFileSync(options.template, \"utf8\");\n if (!template.includes(CONTENT_MARKER))\n throw new Error(\n `[vite-plugin-blog] ${path.relative(config.root, options.template)} has no ${CONTENT_MARKER} marker`,\n );\n return template;\n };\n\n const renderPage = (page: BlogPage) => {\n const helpers = createHelpers(options, content);\n return page.kind === \"post\"\n ? renderPostPage(readTemplate(), page.post, options, helpers)\n : renderListPage(readTemplate(), page.page, options, helpers);\n };\n\n return {\n name: \"vite-plugin-blog\",\n enforce: \"pre\",\n\n async configResolved(resolved) {\n config = resolved;\n options = resolveOptions(userOptions, { root: config.root, base: config.base });\n // Posts and their images may live outside the project (a separate content repo).\n if (config.command === \"serve\") config.server.fs.allow.push(options.dir);\n load = createLoader(options, assetUrl);\n content = await load();\n if (content.issues.length) {\n const message = formatIssues(content.issues, config.root);\n if (config.command === \"build\") throw new Error(message);\n config.logger.error(message);\n }\n },\n\n options(inputOptions) {\n if (config.command !== \"build\") return;\n pageIds.clear();\n const pages: Record<string, string> = {};\n for (const [sitePath, page] of allPages()) {\n const id = fileFor(sitePath);\n pageIds.set(id, page);\n // Entry names: `blog` for the index, `blog-{slug}` for posts, `blog-tag__{tag}` for\n // tags. Slugs can't contain `_`, so a post can never take a tag page's name.\n const rest = sitePath.slice(options.base.length).replace(/\\/$/, \"\");\n pages[rest ? `blog-${rest.replace(/^tag\\//, \"tag__\")}` : \"blog\"] = id;\n }\n return { ...inputOptions, input: addInputs(inputOptions.input, pages) };\n },\n\n resolveId(id) {\n if (id === POSTS_ID) return RESOLVED_POSTS_ID;\n if (id === CSS_ID) return RESOLVED_CSS_ID;\n if (pageIds.has(id)) return id;\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_POSTS_ID)\n return `export const posts = ${JSON.stringify(postSummaries(content.posts))};\\nexport default posts;\\n`;\n if (id === RESOLVED_CSS_ID) return content.css;\n const page = pageIds.get(id);\n if (page) return renderPage(page);\n return null;\n },\n\n configureServer(server: ViteDevServer) {\n server.watcher.add([options.dir, options.template]);\n\n const reload = async (file: string) => {\n if (!isBlogFile(options, file) && !content.files.includes(file)) return;\n content = await load();\n for (const id of [RESOLVED_POSTS_ID, RESOLVED_CSS_ID]) {\n const module = server.moduleGraph.getModuleById(id);\n if (module) server.moduleGraph.invalidateModule(module);\n }\n if (content.issues.length) {\n const message = formatIssues(content.issues, config.root);\n config.logger.error(message, { timestamp: true });\n server.ws.send({ type: \"error\", err: { message, stack: \"\" } });\n } else {\n server.ws.send({ type: \"full-reload\" });\n }\n };\n server.watcher.on(\"add\", reload);\n server.watcher.on(\"change\", reload);\n server.watcher.on(\"unlink\", reload);\n\n server.middlewares.use(async (req, res, next) => {\n try {\n const url = new URL(req.url ?? \"/\", \"http://localhost\");\n const siteBase = options.siteBase.replace(/\\/$/, \"\");\n if (!url.pathname.startsWith(siteBase)) return next();\n const sitePath = url.pathname.slice(siteBase.length).replace(/\\/index\\.html$/, \"/\");\n if (!sitePath.startsWith(options.base.replace(/\\/$/, \"\"))) return next();\n const pages = allPages();\n const page = pages.get(sitePath);\n if (!page) {\n // A page's address without its slash: send it to the real one.\n if (!sitePath.endsWith(\"/\") && pages.has(`${sitePath}/`)) {\n res.statusCode = 301;\n res.setHeader(\"Location\", `${siteBase}${sitePath}/${url.search}`);\n return res.end();\n }\n return next();\n }\n const html = await server.transformIndexHtml(\n `${sitePath}index.html`,\n renderPage(page),\n req.originalUrl,\n );\n res.setHeader(\"Content-Type\", \"text/html; charset=utf-8\");\n res.setHeader(\"Cache-Control\", \"no-cache\");\n res.end(html);\n } catch (error) {\n next(error);\n }\n });\n },\n };\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { MarkdownIt } from \"markdown-it\";\nimport { parse } from \"yaml\";\nimport { parsePostDate, resolveTimeZone } from \"./dates.js\";\nimport { createCodeHighlighter, type CodeHighlighter } from \"./highlight.js\";\nimport { countWords, createMarkdown, fenceLanguages, type RenderEnv } from \"./markdown.js\";\nimport type { AuthorInfo, BlogIssue, BlogOptions, Post, PostSource, TagInfo } from \"./types.js\";\nimport { joinUrl, normalizeBase, readFrontmatter, toRecord, toStringList, toText } from \"./util.js\";\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Options with defaults applied and paths made absolute. */\nexport interface ResolvedBlogOptions extends BlogOptions {\n dir: string;\n template: string;\n /** The blog's path without Vite's base: `/blog/`. */\n base: string;\n /** Vite's `base`: `/`. */\n siteBase: string;\n timeZone: string;\n locale: string;\n wordsPerMinute: number;\n titleSuffix: string;\n}\n\nexport interface BlogContent {\n /** What the build publishes, newest first: everything, with `preview`. */\n posts: Post[];\n issues: BlogIssue[];\n /** CSS for the code highlighting classes used. */\n css: string;\n tags: Record<string, TagInfo>;\n /** Every file read, so dev can reload when one changes. */\n files: string[];\n}\n\nexport function resolveOptions(\n options: BlogOptions,\n vite: { root: string; base: string },\n): ResolvedBlogOptions {\n return {\n ...options,\n dir: path.resolve(vite.root, options.dir),\n template: path.resolve(vite.root, options.template),\n base: normalizeBase(options.base ?? \"/blog/\"),\n siteBase: normalizeBase(vite.base.startsWith(\"/\") ? vite.base : \"/\"),\n timeZone: resolveTimeZone(options.timeZone),\n locale: options.locale ?? \"en-US\",\n wordsPerMinute: options.wordsPerMinute ?? 230,\n titleSuffix: options.titleSuffix ?? \"\",\n };\n}\n\n/** A post's path on the site, without Vite's base: `/blog/vpn-leaks/`. */\nexport function postPath(options: ResolvedBlogOptions, slug: string): string {\n return `${options.base}${slug}/`;\n}\n\nfunction readYamlFile(file: string, issues: BlogIssue[]): Record<string, unknown> | null {\n if (!existsSync(file)) return null;\n try {\n return toRecord(parse(readFileSync(file, \"utf8\")));\n } catch (error) {\n issues.push({ file, message: `invalid YAML: ${(error as Error).message}` });\n return {};\n }\n}\n\nfunction readTags(options: ResolvedBlogOptions, issues: BlogIssue[], files: string[]) {\n if (options.tags) return options.tags;\n const file = path.join(options.dir, \"tags.yml\");\n files.push(file);\n const data = readYamlFile(file, issues);\n if (!data) return null;\n const tags: Record<string, TagInfo> = {};\n for (const [id, value] of Object.entries(data)) {\n const record = toRecord(value);\n tags[id] = {\n name: toText(record.name) || id,\n description: toText(record.description) || undefined,\n };\n }\n return tags;\n}\n\nfunction readAuthors(options: ResolvedBlogOptions, issues: BlogIssue[], files: string[]) {\n if (options.authors) return options.authors;\n const file = path.join(options.dir, \"authors.yml\");\n files.push(file);\n const data = readYamlFile(file, issues);\n if (!data) return null;\n const authors: Record<string, AuthorInfo> = {};\n for (const [id, value] of Object.entries(data)) {\n const record = toRecord(value);\n authors[id] = { name: toText(record.name) || id, url: toText(record.url) || undefined };\n }\n return authors;\n}\n\n/** Every post file under `posts/`: `slug/index.md` or `slug.md`. */\nexport function findPosts(dir: string, issues: BlogIssue[]): { slug: string; file: string }[] {\n const postsDir = path.join(dir, \"posts\");\n if (!existsSync(postsDir)) {\n issues.push({ file: postsDir, message: \"the blog's posts folder doesn't exist\" });\n return [];\n }\n const found = new Map<string, string>();\n for (const entry of readdirSync(postsDir, { withFileTypes: true })) {\n if (entry.name.startsWith(\".\") || entry.name.startsWith(\"_\")) continue;\n let slug: string;\n let file: string;\n if (entry.isDirectory()) {\n file = path.join(postsDir, entry.name, \"index.md\");\n if (!existsSync(file)) continue;\n slug = entry.name;\n } else if (entry.isFile() && entry.name.endsWith(\".md\")) {\n file = path.join(postsDir, entry.name);\n slug = entry.name.slice(0, -3);\n } else continue;\n if (!SLUG.test(slug)) {\n issues.push({\n file,\n message: `\"${slug}\" isn't a valid address: use lowercase letters, numbers and hyphens`,\n });\n continue;\n }\n const other = found.get(slug);\n if (other) {\n issues.push({ file, message: `the address /${slug}/ is already used by ${other}` });\n continue;\n }\n found.set(slug, file);\n }\n return [...found].map(([slug, file]) => ({ slug, file }));\n}\n\n/** Loads, renders and checks the blog. Keeps the highlighter between loads. */\nexport function createLoader(\n options: ResolvedBlogOptions,\n assetUrl: (file: string, slug: string) => string,\n) {\n let highlighter: Promise<CodeHighlighter | null> | undefined;\n let md: MarkdownIt | undefined;\n\n async function setup() {\n highlighter ??=\n options.highlight === false\n ? Promise.resolve(null)\n : createCodeHighlighter({\n themes: options.highlight?.themes ?? { light: \"github-light\", dark: \"github-dark\" },\n classPrefix: options.highlight?.classPrefix ?? \"sk-\",\n });\n const resolved = await highlighter;\n md ??= createMarkdown({\n directives: options.directives ?? {},\n highlighter: resolved,\n extend: options.markdown,\n });\n return { highlighter: resolved, md };\n }\n\n return async function load(): Promise<BlogContent> {\n const { highlighter, md } = await setup();\n const issues: BlogIssue[] = [];\n const files: string[] = [options.template];\n const tags = readTags(options, issues, files);\n const authors = readAuthors(options, issues, files);\n const now = options.now ?? new Date();\n const limits = {\n title: 70,\n description: 160,\n minTags: 0,\n maxTags: Infinity,\n ...options.limits,\n };\n\n const sources: PostSource[] = [];\n for (const { slug, file } of findPosts(options.dir, issues)) {\n files.push(file);\n try {\n const { data, content } = readFrontmatter(readFileSync(file, \"utf8\"));\n sources.push({ slug, file, data, content });\n } catch (error) {\n issues.push({ file, message: `invalid front matter: ${(error as Error).message}` });\n }\n }\n\n // Read the front matter of every post first, so links to drafts and\n // scheduled posts can be told apart from links to nothing.\n const drafts = new Map<string, \"draft\" | \"scheduled\">();\n const included: PostSource[] = [];\n for (const source of sources) {\n const date = parsePostDate(source.data.date, options.timeZone);\n const draft = source.data.draft === true;\n const scheduled = !!date && date.date > now;\n if (!options.preview && (draft || scheduled)) {\n drafts.set(source.slug, draft ? \"draft\" : \"scheduled\");\n } else included.push(source);\n }\n\n if (highlighter) {\n const langs = new Set<string>();\n for (const source of included)\n for (const lang of fenceLanguages(md, source.content)) langs.add(lang);\n const unknown = await highlighter.load(langs);\n if (unknown.length) {\n console.warn(\n `[vite-plugin-blog] no highlighting for: ${unknown.join(\", \")}. Shown as plain text.`,\n );\n }\n }\n\n const posts: Post[] = [];\n const linksByPost = new Map<Post, RenderEnv[\"links\"]>();\n for (const source of included) {\n const problems: string[] = [];\n const report = (message: string) => problems.push(message);\n const { data, slug, file } = source;\n\n const title = toText(data.title);\n if (!title) report(\"title is missing\");\n else if (title.length > limits.title)\n report(`title is ${title.length} characters; the limit is ${limits.title}`);\n const description = toText(data.description);\n if (!description) report(\"description is missing\");\n else if (description.length > limits.description)\n report(\n `description is ${description.length} characters; the limit is ${limits.description}`,\n );\n\n const date = parsePostDate(data.date, options.timeZone);\n if (!date)\n report(\n data.date === undefined\n ? \"date is missing\"\n : `date \"${String(data.date)}\" isn't a date (use 2026-12-02)`,\n );\n const updated =\n data.updated === undefined ? null : parsePostDate(data.updated, options.timeZone);\n if (data.updated !== undefined && !updated)\n report(`updated \"${String(data.updated)}\" isn't a date`);\n if (date && updated && updated.date < date.date) report(\"updated is before date\");\n\n const postTags = toStringList(data.tags);\n if (postTags.length < limits.minTags)\n report(`needs at least ${limits.minTags} tag${limits.minTags === 1 ? \"\" : \"s\"}`);\n if (postTags.length > limits.maxTags)\n report(`has ${postTags.length} tags; the limit is ${limits.maxTags}`);\n if (tags) {\n for (const tag of postTags)\n if (!Object.hasOwn(tags, tag)) report(`tag \"${tag}\" isn't in tags.yml`);\n }\n\n const authorIds = toStringList(data.authors ?? data.author);\n const postAuthors: AuthorInfo[] = [];\n for (const id of authorIds) {\n if (authors && !Object.hasOwn(authors, id)) report(`author \"${id}\" isn't in authors.yml`);\n else postAuthors.push(authors?.[id] ?? { name: id });\n }\n\n let cover: string | undefined;\n const coverValue = toText(data.cover);\n if (coverValue) {\n const coverFile = path.resolve(path.dirname(file), coverValue);\n if (/^[a-z]+:|^\\//i.test(coverValue)) cover = coverValue;\n else if (!existsSync(coverFile)) report(`cover \"${coverValue}\" doesn't exist`);\n else {\n cover = assetUrl(coverFile, slug);\n files.push(coverFile);\n }\n }\n\n // The front matter's lines, so reported line numbers match the file.\n const raw = readFileSync(file, \"utf8\").replace(/^\\uFEFF/, \"\");\n const env: RenderEnv = {\n post: source,\n lineOffset: raw.slice(0, raw.length - source.content.length).split(\"\\n\").length - 1,\n error: report,\n assetUrl: (asset) => assetUrl(asset, slug),\n toc: [],\n links: [],\n images: [],\n imageCount: 0,\n };\n let html = \"\";\n try {\n html = md.render(source.content, env);\n } catch (error) {\n report(`couldn't render: ${(error as Error).message}`);\n }\n files.push(...env.images);\n\n const words = countWords(source.content);\n const sitePath = postPath(options, slug);\n const post: Post = {\n slug,\n url: joinUrl(options.siteBase, sitePath),\n canonical: options.site\n ? joinUrl(options.site, joinUrl(options.siteBase, sitePath))\n : undefined,\n file,\n title,\n description,\n date: date?.date ?? new Date(0),\n dateHasTime: date?.hasTime ?? false,\n updated: updated?.date,\n tags: postTags,\n authors: postAuthors,\n draft: data.draft === true,\n scheduled: !!date && date.date > now,\n featured: data.featured === true,\n series: toText(data.series) || undefined,\n cover,\n data,\n html,\n toc: env.toc,\n readingMinutes: Math.max(1, Math.ceil(words / options.wordsPerMinute)),\n words,\n };\n for (const message of options.validate?.(post) ?? []) report(message);\n for (const message of problems) issues.push({ file, message });\n linksByPost.set(post, env.links);\n posts.push(post);\n }\n\n // Links between posts, and to site pages when the site says which exist.\n const published = new Set(posts.map((post) => post.slug));\n const usedTags = new Set(posts.flatMap((post) => post.tags));\n for (const [post, links] of linksByPost) {\n for (const { href, line } of links) {\n const where = line ? `line ${line}: ` : \"\";\n const pathname = href.split(/[?#]/)[0]!;\n if (pathname.startsWith(options.base)) {\n const rest = pathname.slice(options.base.length).replace(/(?:\\/index\\.html|\\/)$/, \"\");\n if (!rest) continue; // the index\n const tag = /^tag\\/([^/]+)$/.exec(rest)?.[1];\n if (tag) {\n if (options.tagPages !== false && usedTags.has(tag)) continue;\n issues.push({\n file: post.file,\n message: `${where}link to ${href} goes nowhere: no published post has the tag \"${tag}\"`,\n });\n continue;\n }\n if (rest.includes(\"/\")) {\n issues.push({ file: post.file, message: `${where}link to ${href} goes nowhere` });\n continue;\n }\n if (published.has(rest)) continue;\n const state = drafts.get(rest);\n issues.push({\n file: post.file,\n message: state\n ? `${where}link to ${href} goes to a ${state} post, which isn't published yet`\n : `${where}link to ${href} goes nowhere: there's no post \"${rest}\"`,\n });\n } else if (options.isKnownPath && !options.isKnownPath(pathname)) {\n issues.push({ file: post.file, message: `${where}link to ${href} goes nowhere` });\n }\n }\n }\n\n posts.sort((a, b) => b.date.getTime() - a.date.getTime() || a.slug.localeCompare(b.slug));\n return {\n posts,\n issues,\n css: highlighter?.css() ?? \"\",\n tags: tags ?? {},\n files: [...new Set(files)],\n };\n };\n}\n\n/** Whether `file` is something the blog reads: in its folder, or its page shell. */\nexport function isBlogFile(options: ResolvedBlogOptions, file: string): boolean {\n const relative = path.relative(options.dir, file);\n return file === options.template || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n\n/** The issues as one message, by file, with paths relative to `root`. */\nexport function formatIssues(issues: BlogIssue[], root: string): string {\n const byFile = new Map<string, string[]>();\n for (const { file, message } of issues) {\n const name = path.relative(root, file) || file;\n byFile.set(name, [...(byFile.get(name) ?? []), message]);\n }\n const lines = [\n `[vite-plugin-blog] ${issues.length} problem${issues.length === 1 ? \"\" : \"s\"} in the blog:`,\n ];\n for (const [file, messages] of byFile) {\n lines.push(` ${file}`);\n for (const message of messages) lines.push(` - ${message}`);\n }\n return lines.join(\"\\n\");\n}\n","/**\n * Dates and times from frontmatter. A post can give a date (`2026-10-20`), a\n * date and time (`2026-10-20 14:30` or `2026-10-20T14:30:00`), or either with\n * an offset (`2026-10-20T14:30:00-04:00`, `…Z`). A value without an offset is\n * read in the blog\"s time zone, so the same frontmatter means the same moment\n * on every build machine, and is shown in that time zone too.\n */\n\n/** A post\"s date and whether its frontmatter gave a time, so a date alone is never shown with \"12:00 AM\". */\nexport interface PostDate {\n date: Date;\n hasTime: boolean;\n}\n\n// `2026-10-20`, then an optional `T` or space and `HH:mm[:ss[.sss]]`, then an optional `Z` or `±HH[:]mm`.\nconst DATE_TIME =\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3})\\d*)?)?)?\\s*(Z|[+-]\\d{2}:?\\d{2})?$/i;\n\n/** Whether `timeZone` is a time zone this runtime knows, such as `UTC` or `America/New_York`. */\nexport function isTimeZone(timeZone: string): boolean {\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone });\n return true;\n } catch {\n return false;\n }\n}\n\nconst warnedZones = new Set<string>();\n\n/** The `timeZone` option, or `UTC` (with a warning, once) when it isn\"t a time zone this runtime knows. */\nexport function resolveTimeZone(timeZone: string | undefined): string {\n if (!timeZone) return \"UTC\";\n if (isTimeZone(timeZone)) return timeZone;\n if (!warnedZones.has(timeZone)) {\n warnedZones.add(timeZone);\n console.warn(\n `[vite-plugin-blog] \"${timeZone}\" is not a time zone; using UTC. Use an IANA name such as \"America/New_York\".`,\n );\n }\n return \"UTC\";\n}\n\nconst offsetFormats = new Map<string, Intl.DateTimeFormat>();\n\n/** How far `timeZone`\"s wall clock is ahead of UTC at `instant`, in milliseconds (negative west of UTC). */\nexport function zoneOffset(instant: number, timeZone: string): number {\n let format = offsetFormats.get(timeZone);\n if (!format) {\n format = new Intl.DateTimeFormat(\"en-US\", {\n timeZone,\n hourCycle: \"h23\",\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n });\n offsetFormats.set(timeZone, format);\n }\n const parts = Object.fromEntries(\n format.formatToParts(instant).map(({ type, value }) => [type, Number(value)]),\n );\n const wall = Date.UTC(\n parts.year,\n parts.month - 1,\n parts.day,\n parts.hour,\n parts.minute,\n parts.second,\n );\n return wall - Math.floor(instant / 1000) * 1000;\n}\n\n/** The instant a wall-clock time in `timeZone` names, using the offset in force then (daylight saving included). */\nfunction fromZonedTime(wall: number, timeZone: string): number {\n const first = wall - zoneOffset(wall, timeZone);\n const second = wall - zoneOffset(first, timeZone);\n return second;\n}\n\n/**\n * Reads a frontmatter date. Strings in the forms above are read exactly; a\n * `Date` (as other YAML parsers produce) counts as having a time unless it\n * is midnight UTC. Anything else is `null`.\n */\nexport function parsePostDate(value: unknown, timeZone = \"UTC\"): PostDate | null {\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) return null;\n const midnight =\n value.getUTCHours() === 0 && value.getUTCMinutes() === 0 && value.getUTCSeconds() === 0;\n return { date: value, hasTime: !midnight };\n }\n if (typeof value !== \"string\") return null;\n const match = DATE_TIME.exec(value.trim());\n if (!match) return null;\n const [, year, month, day, hour, minute, second = \"0\", millisecond = \"0\", offset] = match;\n const hasTime = hour !== undefined;\n const wall = Date.UTC(\n Number(year),\n Number(month) - 1,\n Number(day),\n hasTime ? Number(hour) : 0,\n hasTime ? Number(minute) : 0,\n Number(second),\n Number(millisecond.padEnd(3, \"0\")),\n );\n // Date.UTC rolls over impossible dates (2026-02-30), so check the date survived intact.\n const check = new Date(wall);\n if (check.getUTCMonth() !== Number(month) - 1 || check.getUTCDate() !== Number(day)) return null;\n\n if (!offset) return { date: new Date(fromZonedTime(wall, timeZone)), hasTime };\n if (offset.toUpperCase() === \"Z\") return { date: new Date(wall), hasTime };\n const sign = offset.startsWith(\"-\") ? -1 : 1;\n const digits = offset.slice(1).replace(\":\", \"\");\n const minutes = Number(digits.slice(0, 2)) * 60 + Number(digits.slice(2));\n return { date: new Date(wall - sign * minutes * 60_000), hasTime };\n}\n\nexport interface DateDisplay {\n locale: string;\n timeZone: string;\n dateFormat: Intl.DateTimeFormatOptions;\n timeFormat: Intl.DateTimeFormatOptions;\n /** How a date and a time are joined: `{date} at {time}`. */\n dateTime: string;\n}\n\n/** A post date for readers: the date, plus the time when the frontmatter gave one, in the blog\"s time zone. */\nexport function formatPostDate({ date, hasTime }: PostDate, display: DateDisplay): string {\n const { locale, timeZone } = display;\n const day = new Intl.DateTimeFormat(locale, { timeZone, ...display.dateFormat }).format(date);\n if (!hasTime) return day;\n const time = new Intl.DateTimeFormat(locale, { timeZone, ...display.timeFormat }).format(date);\n return display.dateTime.replace(\"{date}\", day).replace(\"{time}\", time);\n}\n\n/** The calendar date in `timeZone`, as `YYYY-MM-DD`. */\nexport function toZonedIsoDate(date: Date, timeZone: string): string {\n const parts = Object.fromEntries(\n new Intl.DateTimeFormat(\"en-US\", {\n timeZone,\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n })\n .formatToParts(date)\n .map(({ type, value }) => [type, value]),\n );\n return `${parts.year}-${parts.month}-${parts.day}`;\n}\n\n/** A `<time datetime>` value: the date alone, or the exact moment when there is a time. */\nexport function toDateTimeAttribute({ date, hasTime }: PostDate, timeZone: string): string {\n return hasTime ? date.toISOString() : toZonedIsoDate(date, timeZone);\n}\n","import { transformerStyleToClass } from \"@shikijs/transformers\";\nimport {\n bundledLanguages,\n bundledLanguagesAlias,\n createHighlighter,\n type BundledLanguage,\n type Highlighter,\n} from \"shiki\";\nimport { escapeHtml } from \"./util.js\";\n\nexport interface CodeHighlighter {\n /** Loads the grammars these fence languages need. Unknown languages are returned. */\n load(langs: Iterable<string>): Promise<string[]>;\n /** A `<pre>` with classes only, no `style` attributes. */\n highlight(code: string, lang: string): string;\n /** The CSS for every class used so far, plus the light and dark rules. */\n css(): string;\n}\n\nconst PLAIN = new Set([\"\", \"text\", \"txt\", \"plain\", \"plaintext\"]);\n\nfunction isBundled(lang: string): lang is BundledLanguage {\n return Object.hasOwn(bundledLanguages, lang) || Object.hasOwn(bundledLanguagesAlias, lang);\n}\n\n/** A plain block, for no language or highlighting turned off. */\nexport function plainBlock(code: string, lang: string): string {\n const attr = lang ? ` data-lang=\"${escapeHtml(lang)}\"` : \"\";\n return `<pre class=\"shiki\"${attr}><code>${escapeHtml(code)}</code></pre>`;\n}\n\n/**\n * Shiki with both themes as CSS custom properties, then turned into classes by\n * `transformerStyleToClass`. The page gets no `style` attributes, so it works\n * under `style-src 'self'`, and `light-dark()` picks the theme from the page's\n * `color-scheme`, so a site's own light/dark switch applies without extra rules.\n */\nexport async function createCodeHighlighter(options: {\n themes: { light: string; dark: string };\n classPrefix: string;\n}): Promise<CodeHighlighter> {\n const highlighter: Highlighter = await createHighlighter({\n themes: [options.themes.light, options.themes.dark],\n langs: [],\n });\n const toClass = transformerStyleToClass({ classPrefix: options.classPrefix });\n const loaded = new Set<string>();\n\n return {\n async load(langs) {\n const unknown: string[] = [];\n for (const raw of langs) {\n const lang = raw.toLowerCase();\n if (PLAIN.has(lang) || loaded.has(lang)) continue;\n if (!isBundled(lang)) {\n unknown.push(raw);\n continue;\n }\n await highlighter.loadLanguage(lang);\n loaded.add(lang);\n }\n return unknown;\n },\n highlight(code, raw) {\n const lang = raw.toLowerCase();\n if (!loaded.has(lang)) return plainBlock(code, raw);\n return highlighter.codeToHtml(code, {\n lang,\n themes: options.themes,\n defaultColor: false,\n transformers: [\n toClass,\n {\n pre(node) {\n node.properties[\"data-lang\"] = raw;\n delete node.properties.tabindex;\n },\n },\n ],\n });\n },\n css() {\n return [\n \"/* Code highlighting from @binarynoir/vite-plugin-blog. Generated: do not edit. */\",\n \".shiki { color: light-dark(var(--shiki-light), var(--shiki-dark)); background-color: light-dark(var(--shiki-light-bg), var(--shiki-dark-bg)); }\",\n \".shiki span { color: light-dark(var(--shiki-light), var(--shiki-dark)); }\",\n toClass.getCSS(),\n \"\",\n ].join(\"\\n\");\n },\n };\n}\n","import { parse } from \"yaml\";\n\nconst HTML_ESCAPES: Record<string, string> = {\n \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\",\n};\n\n/** Escapes the characters that are special in HTML text and attribute values. */\nexport function escapeHtml(value: string): string {\n return value.replace(/[&<>\"']/g, (character) => HTML_ESCAPES[character]!);\n}\n\n/** A URL with a scheme (`https:`, `mailto:`) or protocol-relative (`//cdn`). */\nexport function isExternalUrl(url: string): boolean {\n return /^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i.test(url);\n}\n\n/** `base` and `path` joined with exactly one slash between them. */\nexport function joinUrl(base: string, path: string): string {\n return `${base.replace(/\\/+$/, \"\")}/${path.replace(/^\\/+/, \"\")}`;\n}\n\n/** `/blog`, `blog/` or `blog` as `/blog/`. */\nexport function normalizeBase(base: string): string {\n const trimmed = base.replace(/^\\/+|\\/+$/g, \"\");\n return trimmed ? `/${trimmed}/` : \"/\";\n}\n\n// An opening `---` line, an optional YAML body, and a closing `---` line.\nconst FRONTMATTER = /^---[ \\t]*\\r?\\n(?:([\\s\\S]*?)\\r?\\n)?---[ \\t]*(?:\\r?\\n|$)/;\n\n/**\n * Splits a Markdown file into its YAML front matter and the content after it.\n * Invalid YAML throws, so callers can report it.\n */\nexport function readFrontmatter(raw: string): { data: Record<string, unknown>; content: string } {\n const source = raw.replace(/^\\uFEFF/, \"\");\n const match = FRONTMATTER.exec(source);\n if (!match) return { data: {}, content: source };\n const data: unknown = match[1] ? parse(match[1], { schema: \"core\" }) : null;\n return { data: toRecord(data), content: source.slice(match[0].length) };\n}\n\nexport function toRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\nexport function toText(value: unknown): string {\n return typeof value === \"string\" ? value.trim() : typeof value === \"number\" ? String(value) : \"\";\n}\n\n/** A list, or a single string split on commas. */\nexport function toStringList(value: unknown): string[] {\n const values = Array.isArray(value) ? value : typeof value === \"string\" ? value.split(\",\") : [];\n return values.map(toText).filter(Boolean);\n}\n\n/** Lowercase words joined by hyphens: \"Is your VPN working?\" is `is-your-vpn-working`. */\nexport function slugify(text: string): string {\n return text\n .normalize(\"NFKD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .toLowerCase()\n .replace(/&[a-z]+;/g, \"\")\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { imageSize } from \"image-size\";\nimport markdownIt, { type Env, type MarkdownIt, type Token } from \"markdown-it\";\nimport { BUILT_IN_DIRECTIVES, directivesPlugin } from \"./directives.js\";\nimport { plainBlock, type CodeHighlighter } from \"./highlight.js\";\nimport type { Directive, PostSource, TocEntry } from \"./types.js\";\nimport { escapeHtml, isExternalUrl, slugify } from \"./util.js\";\n\n/** What a render collects, and what it needs from the plugin. */\nexport interface RenderEnv extends Env {\n post: PostSource;\n /** Lines before the Markdown (the front matter), so reported lines match the file. */\n lineOffset: number;\n error(message: string): void;\n /** The URL a page should use for a local file next to the post. */\n assetUrl(file: string): string;\n toc: TocEntry[];\n /** Links to site paths (no scheme, starting with `/`), for checking. */\n links: { href: string; line?: number }[];\n /** Local images this post uses. */\n images: string[];\n imageCount: number;\n}\n\nfunction readSize(file: string): { width?: number; height?: number } {\n try {\n const buffer = readFileSync(file);\n const { width, height } = imageSize(buffer);\n return { width, height };\n } catch {\n return {};\n }\n}\n\n/** markdown-it types `env` loosely; this plugin always passes a `RenderEnv`. */\nexport function asEnv(env: Env | undefined): RenderEnv {\n return env as RenderEnv;\n}\n\n/** A token attribute as a string (markdown-it allows numbers). */\nfunction attr(token: Token, name: string): string | undefined {\n const value = token.attrGet(name);\n return value === null ? undefined : String(value);\n}\n\nfunction lineOf(token: Token, env: RenderEnv): string {\n return token.map ? `line ${token.map[0] + env.lineOffset + 1}: ` : \"\";\n}\n\n/** Headings get ids and a `#` link, and `##`/`###` go in the table of contents. */\nfunction headings(md: MarkdownIt): void {\n md.core.ruler.push(\"blog_headings\", (state) => {\n const env = asEnv(state.env);\n const used = new Map<string, number>();\n const tokens = state.tokens;\n for (let i = 0; i < tokens.length; i++) {\n const open = tokens[i]!;\n if (open.type !== \"heading_open\") continue;\n const inline = tokens[i + 1]!;\n const text = (inline.children ?? [])\n .filter((child) => child.type === \"text\" || child.type === \"code_inline\")\n .map((child) => child.content)\n .join(\"\")\n .trim();\n const base = attr(open, \"id\") ?? (slugify(text) || \"section\");\n const count = used.get(base) ?? 0;\n used.set(base, count + 1);\n const id = count ? `${base}-${count}` : base;\n open.attrSet(\"id\", id);\n const level = Number(open.tag.slice(1));\n if (level === 2 || level === 3) env.toc.push({ level, id, text });\n if (level === 1)\n env.error(`${lineOf(open, env)}use the front matter title, not a \"#\" heading`);\n }\n });\n const defaultClose =\n md.renderer.rules.heading_close ??\n ((tokens, index, options, _env, self) => self.renderToken(tokens, index, options));\n md.renderer.rules.heading_close = (tokens, index, options, env, self) => {\n const heading = tokens[index - 2];\n const id = heading && attr(heading, \"id\");\n const anchor = id\n ? ` <a class=\"heading-anchor\" href=\"#${escapeHtml(id)}\" aria-hidden=\"true\" tabindex=\"-1\">#</a>`\n : \"\";\n return anchor + defaultClose(tokens, index, options, env, self);\n };\n}\n\n/**\n * An image alone in its paragraph becomes a `<figure>`, with its title as the\n * caption. Every image needs alt text. Local images must exist, and get their\n * width and height, so the page doesn't shift as they load.\n */\nfunction images(md: MarkdownIt): void {\n md.core.ruler.push(\"blog_figures\", (state) => {\n const tokens = state.tokens;\n for (let i = 0; i + 2 < tokens.length; i++) {\n const [open, inline, close] = [tokens[i]!, tokens[i + 1]!, tokens[i + 2]!];\n if (open.type !== \"paragraph_open\" || close.type !== \"paragraph_close\") continue;\n const children = (inline.children ?? []).filter(\n (child) => !(child.type === \"text\" && !child.content.trim()),\n );\n if (children.length !== 1 || children[0]!.type !== \"image\") continue;\n open.hidden = true;\n close.hidden = true;\n children[0]!.meta = { ...children[0]!.meta, figure: true };\n }\n });\n\n md.renderer.rules.image = (tokens, index, options, rawEnv, self) => {\n const env = asEnv(rawEnv);\n const token = tokens[index]!;\n const alt = self.renderInlineAsText(token.children ?? [], options, env).trim();\n const src = attr(token, \"src\") ?? \"\";\n const title = attr(token, \"title\") ?? \"\";\n const line = token.meta?.line as number | undefined;\n const where = line ? `line ${line}: ` : \"\";\n if (!alt) env.error(`${where}image \"${src}\" has no alt text`);\n\n const attrs: string[] = [];\n let url = src;\n if (src && !isExternalUrl(src) && !src.startsWith(\"/\") && !src.startsWith(\"data:\")) {\n const file = path.resolve(path.dirname(env.post.file), decodeURI(src.split(/[?#]/)[0]!));\n if (!existsSync(file)) {\n env.error(`${where}image \"${src}\" doesn't exist`);\n } else {\n env.images.push(file);\n url = env.assetUrl(file);\n const { width, height } = readSize(file);\n if (width && height) attrs.push(`width=\"${width}\"`, `height=\"${height}\"`);\n }\n }\n env.imageCount++;\n if (env.imageCount > 1) attrs.push('loading=\"lazy\"');\n attrs.push('decoding=\"async\"');\n\n const img = `<img src=\"${escapeHtml(url)}\" alt=\"${escapeHtml(alt)}\" ${attrs.join(\" \")}>`;\n if (!token.meta?.figure) return img;\n const caption = title ? `<figcaption>${md.renderInline(title, env)}</figcaption>` : \"\";\n return `<figure>${img}${caption}</figure>\\n`;\n };\n}\n\n/**\n * Records links to site paths for checking after every post has rendered, and\n * gives images their line in the file (inline tokens have none of their own).\n */\nfunction links(md: MarkdownIt): void {\n md.core.ruler.push(\"blog_links\", (state) => {\n const env = asEnv(state.env);\n for (const block of state.tokens) {\n const line = block.map ? block.map[0] + env.lineOffset + 1 : undefined;\n for (const child of block.children ?? []) {\n if (child.type === \"image\") child.meta = { ...child.meta, line };\n if (child.type !== \"link_open\") continue;\n const href = attr(child, \"href\") ?? \"\";\n if (href.startsWith(\"/\") && !href.startsWith(\"//\")) env.links.push({ href, line });\n }\n }\n });\n}\n\n/** Fenced code through Shiki (or plain), each in a `.code-block` with its language. */\nfunction fences(md: MarkdownIt, highlighter: CodeHighlighter | null): void {\n md.renderer.rules.fence = (tokens, index) => {\n const token = tokens[index]!;\n const lang = token.info.trim().split(/\\s+/)[0] ?? \"\";\n const code = token.content;\n const html = highlighter ? highlighter.highlight(code, lang) : plainBlock(code, lang);\n const attr = lang ? ` data-lang=\"${escapeHtml(lang)}\"` : \"\";\n return `<div class=\"code-block\"${attr}>${html}</div>\\n`;\n };\n}\n\n/** The fence languages in some Markdown, so their grammars can load before rendering. */\nexport function fenceLanguages(md: MarkdownIt, content: string): Set<string> {\n const langs = new Set<string>();\n const walk = (tokens: Token[]) => {\n for (const token of tokens) {\n if (token.type === \"fence\") {\n const lang = token.info.trim().split(/\\s+/)[0];\n if (lang) langs.add(lang);\n }\n }\n };\n const scratch: RenderEnv = {\n post: { slug: \"\", file: \"\", data: {}, content },\n lineOffset: 0,\n error() {},\n assetUrl: (file) => file,\n toc: [],\n links: [],\n images: [],\n imageCount: 0,\n };\n walk(md.parse(content, scratch));\n return langs;\n}\n\nexport function createMarkdown(options: {\n directives: Record<string, Directive>;\n highlighter: CodeHighlighter | null;\n extend?: (md: MarkdownIt) => void;\n}): MarkdownIt {\n const md = markdownIt({ html: true, linkify: true, typographer: true });\n directivesPlugin(md, { ...BUILT_IN_DIRECTIVES, ...options.directives });\n headings(md);\n images(md);\n links(md);\n fences(md, options.highlighter);\n options.extend?.(md);\n return md;\n}\n\n/** Words in the post's prose, not counting code. */\nexport function countWords(content: string): number {\n return content\n .replace(/^[ \\t]*(`{3,}|~{3,})[^\\n]*\\n[\\s\\S]*?^[ \\t]*\\1[ \\t]*$/gm, \"\")\n .replace(/!\\[[^\\]]*\\]\\([^)]*\\)/g, \"\")\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, \"$1\")\n .replace(/<[^>]+>/g, \" \")\n .replace(/^:::.*$/gm, \"\")\n .split(/\\s+/)\n .filter((word) => /[\\p{L}\\p{N}]/u.test(word)).length;\n}\n","import type { MarkdownIt, StateBlock } from \"markdown-it\";\nimport type { Directive } from \"./types.js\";\nimport { escapeHtml } from \"./util.js\";\nimport { asEnv, type RenderEnv } from \"./markdown.js\";\n\nconst OPENING = /^:::[ \\t]*([a-z][\\w-]*)(?:[ \\t]+(.*?))?[ \\t]*$/i;\nconst CLOSING = /^:::[ \\t]*$/;\n\nfunction callout(kind: string, label: string): Directive {\n return {\n kind: \"container\",\n render: ({ args, body }) =>\n `<aside class=\"callout callout-${kind}\">\\n<p class=\"callout-title\">${escapeHtml(args || label)}</p>\\n${body}</aside>\\n`,\n };\n}\n\n/** `::: note`, `::: tip` and `::: warning`, with an optional title after the name. */\nexport const BUILT_IN_DIRECTIVES: Record<string, Directive> = {\n note: callout(\"note\", \"Note\"),\n tip: callout(\"tip\", \"Tip\"),\n warning: callout(\"warning\", \"Warning\"),\n};\n\nfunction lineText(state: StateBlock, line: number): string {\n return state.src.slice(state.bMarks[line]! + state.tShift[line]!, state.eMarks[line]);\n}\n\n/**\n * Adds `:::name args` blocks. Leaf directives take one line. Containers run to a\n * line holding only `:::`, can nest, and their body is parsed as Markdown.\n * An unknown name is reported, not printed as text.\n */\nexport function directivesPlugin(md: MarkdownIt, directives: Record<string, Directive>): void {\n md.block.ruler.before(\n \"fence\",\n \"blog_directive\",\n (state, startLine, endLine, silent) => {\n if (state.sCount[startLine]! - state.blkIndent >= 4) return false;\n const match = OPENING.exec(lineText(state, startLine));\n if (!match) return false;\n const name = match[1]!.toLowerCase();\n const args = match[2] ?? \"\";\n const directive = Object.hasOwn(directives, name) ? directives[name] : undefined;\n if (silent) return true;\n\n if (!directive || directive.kind === \"leaf\") {\n const token = state.push(\"blog_directive\", \"\", 0);\n token.info = name;\n token.meta = { args };\n token.map = [startLine, startLine + 1];\n state.line = startLine + 1;\n return true;\n }\n\n // Find the matching closing line, counting nested containers.\n let depth = 1;\n let line = startLine + 1;\n for (; line < endLine; line++) {\n if (state.sCount[line]! < state.blkIndent) break;\n const text = lineText(state, line);\n if (CLOSING.test(text)) {\n if (--depth === 0) break;\n } else {\n const inner = OPENING.exec(text);\n const innerName = inner?.[1]?.toLowerCase();\n if (innerName && directives[innerName]?.kind === \"container\") depth++;\n }\n }\n const closed = depth === 0;\n\n const open = state.push(\"blog_directive_open\", \"\", 1);\n open.info = name;\n open.meta = { args, closed };\n open.map = [startLine, line];\n open.block = true;\n\n const oldParent = state.parentType;\n const oldLineMax = state.lineMax;\n state.parentType = \"blog_directive\";\n state.lineMax = line;\n state.md.block.tokenize(state, startLine + 1, line);\n state.parentType = oldParent;\n state.lineMax = oldLineMax;\n\n const close = state.push(\"blog_directive_close\", \"\", -1);\n close.info = name;\n close.block = true;\n state.line = closed ? line + 1 : line;\n return true;\n },\n { alt: [\"paragraph\", \"reference\", \"blockquote\", \"list\"] },\n );\n\n const report = (env: RenderEnv, line: number | undefined, message: string) =>\n env.error(line === undefined ? message : `line ${line + 1}: ${message}`);\n\n md.renderer.rules.blog_directive = (tokens, index, _options, rawEnv) => {\n const env = asEnv(rawEnv);\n const token = tokens[index]!;\n const directive = Object.hasOwn(directives, token.info) ? directives[token.info] : undefined;\n const line = token.map?.[0] === undefined ? undefined : token.map[0] + env.lineOffset;\n if (!directive) {\n report(env, line, `unknown directive \"::: ${token.info}\"`);\n return \"\";\n }\n return directive.render({\n args: (token.meta?.args as string) ?? \"\",\n body: \"\",\n post: env.post,\n md,\n error: (message) => report(env, line, `::: ${token.info}: ${message}`),\n });\n };\n\n // A container renders its children itself, so its body can be wrapped.\n md.renderer.rules.blog_directive_open = (tokens, index, options, rawEnv) => {\n const env = asEnv(rawEnv);\n const open = tokens[index]!;\n const line = open.map?.[0] === undefined ? undefined : open.map[0] + env.lineOffset;\n if (!open.meta?.closed) report(env, line, `\"::: ${open.info}\" has no closing \":::\"`);\n let depth = 0;\n let end = index + 1;\n for (; end < tokens.length; end++) {\n const type = tokens[end]!.type;\n if (type === \"blog_directive_open\") depth++;\n else if (type === \"blog_directive_close\" && depth-- === 0) break;\n }\n const body = md.renderer.render(tokens.slice(index + 1, end), options, env);\n // Hide the children, already rendered, from the outer pass.\n for (let i = index + 1; i <= end && i < tokens.length; i++) {\n tokens[i]!.hidden = true;\n tokens[i]!.type = \"blog_directive_rendered\";\n tokens[i]!.children = null;\n tokens[i]!.content = \"\";\n }\n const directive = directives[open.info]!;\n return directive.render({\n args: (open.meta?.args as string) ?? \"\",\n body,\n post: env.post,\n md,\n error: (message) => report(env, line, `::: ${open.info}: ${message}`),\n });\n };\n md.renderer.rules.blog_directive_rendered = () => \"\";\n}\n","import type { BlogContent, ResolvedBlogOptions } from \"./content.js\";\nimport { formatPostDate, toDateTimeAttribute } from \"./dates.js\";\nimport type { ListPage, Post, RenderHelpers, TocEntry } from \"./types.js\";\nimport { escapeHtml, joinUrl } from \"./util.js\";\n\nexport const HEAD_MARKER = \"<!--blog:head-->\";\nexport const CONTENT_MARKER = \"<!--blog:content-->\";\n\nfunction meta(attribute: \"name\" | \"property\", key: string, value: string | undefined): string {\n return value ? `<meta ${attribute}=\"${key}\" content=\"${escapeHtml(value)}\">` : \"\";\n}\n\nexport function renderToc(toc: TocEntry[]): string {\n if (toc.length < 2) return \"\";\n const items = toc\n .map(\n (entry) =>\n `<li class=\"toc-${entry.level}\"><a href=\"#${escapeHtml(entry.id)}\">${escapeHtml(entry.text)}</a></li>`,\n )\n .join(\"\");\n return `<nav class=\"toc\" aria-label=\"On this page\"><p class=\"toc-title\">On this page</p><ol>${items}</ol></nav>`;\n}\n\n/** Tags with published posts, in `tags.yml` order, then any others by name. */\nexport function usedTags(content: BlogContent): string[] {\n const used = new Set(content.posts.flatMap((post) => post.tags));\n const known = Object.keys(content.tags).filter((tag) => used.has(tag));\n const others = [...used].filter((tag) => !Object.hasOwn(content.tags, tag)).sort();\n return [...known, ...others];\n}\n\n/** A path on the site without Vite's base: the index is `/blog/`, a tag `/blog/tag/dns/`. */\nexport function listPath(options: ResolvedBlogOptions, tag?: string): string {\n return tag ? `${options.base}tag/${tag}/` : options.base;\n}\n\n/** The index, then a page per used tag (unless `tagPages` is off). */\nexport function listPages(options: ResolvedBlogOptions, content: BlogContent): ListPage[] {\n const page = (sitePath: string) => ({\n url: joinUrl(options.siteBase, sitePath),\n canonical: options.site\n ? joinUrl(options.site, joinUrl(options.siteBase, sitePath))\n : undefined,\n });\n const pages: ListPage[] = [\n {\n kind: \"index\",\n ...page(listPath(options)),\n title: options.index?.title ?? \"Blog\",\n description: options.index?.description ?? \"\",\n posts: content.posts,\n },\n ];\n if (options.tagPages === false) return pages;\n for (const tag of usedTags(content)) {\n const info = content.tags[tag];\n pages.push({\n kind: \"tag\",\n ...page(listPath(options, tag)),\n title: info?.name ?? tag,\n description: info?.description ?? \"\",\n tag,\n posts: content.posts.filter((post) => post.tags.includes(tag)),\n });\n }\n return pages;\n}\n\nexport function createHelpers(options: ResolvedBlogOptions, content: BlogContent): RenderHelpers {\n const display = {\n locale: options.locale,\n timeZone: options.timeZone,\n dateFormat: { year: \"numeric\", month: \"long\", day: \"numeric\" } as const,\n timeFormat: { hour: \"numeric\", minute: \"2-digit\", timeZoneName: \"short\" } as const,\n dateTime: \"{date} at {time}\",\n };\n const formatDate = (date: Date, hasTime = false) => formatPostDate({ date, hasTime }, display);\n const dateAttribute = (date: Date, hasTime = false) =>\n toDateTimeAttribute({ date, hasTime }, options.timeZone);\n\n const tags = usedTags(content);\n const indexUrl = joinUrl(options.siteBase, listPath(options));\n const tagUrl = (tag: string) => joinUrl(options.siteBase, listPath(options, tag));\n /** A tag as a list item, linked to its page when tag pages are on. */\n const tagItem = (tag: string) => {\n const name = escapeHtml(content.tags[tag]?.name ?? tag);\n return options.tagPages === false\n ? `<li class=\"tag\">${name}</li>`\n : `<li class=\"tag\"><a href=\"${escapeHtml(tagUrl(tag))}\">${name}</a></li>`;\n };\n\n const renderHead = (post: Post) =>\n [\n `<title>${escapeHtml(post.title + options.titleSuffix)}</title>`,\n meta(\"name\", \"description\", post.description),\n post.draft || post.scheduled ? '<meta name=\"robots\" content=\"noindex\">' : \"\",\n post.canonical ? `<link rel=\"canonical\" href=\"${escapeHtml(post.canonical)}\">` : \"\",\n meta(\"property\", \"og:type\", \"article\"),\n meta(\"property\", \"og:title\", post.title),\n meta(\"property\", \"og:description\", post.description),\n meta(\"property\", \"og:url\", post.canonical),\n meta(\"property\", \"article:published_time\", post.date.toISOString()),\n meta(\"property\", \"article:modified_time\", post.updated?.toISOString()),\n ...post.tags.map((tag) => meta(\"property\", \"article:tag\", content.tags[tag]?.name ?? tag)),\n ]\n .filter(Boolean)\n .join(\"\\n \");\n\n const renderArticle = (post: Post) => {\n const tags = post.tags.map(tagItem).join(\"\");\n const updated = post.updated\n ? ` · Updated <time datetime=\"${dateAttribute(post.updated)}\">${formatDate(post.updated)}</time>`\n : \"\";\n return [\n '<article class=\"post\">',\n '<header class=\"post-header\">',\n `<h1>${escapeHtml(post.title)}</h1>`,\n `<p class=\"post-description\">${escapeHtml(post.description)}</p>`,\n `<p class=\"post-meta\"><time datetime=\"${dateAttribute(post.date, post.dateHasTime)}\">${formatDate(post.date, post.dateHasTime)}</time>${updated} · ${post.readingMinutes} min read</p>`,\n tags ? `<ul class=\"post-tags\">${tags}</ul>` : \"\",\n \"</header>\",\n renderToc(post.toc),\n `<div class=\"prose\" data-pagefind-body>\\n${post.html}</div>`,\n \"</article>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n };\n\n const indexTitle = options.index?.title ?? \"Blog\";\n\n const renderListHead = (page: ListPage) => {\n const title = page.kind === \"index\" ? page.title : `${page.title} · ${indexTitle}`;\n return [\n `<title>${escapeHtml(title + options.titleSuffix)}</title>`,\n meta(\"name\", \"description\", page.description),\n page.canonical ? `<link rel=\"canonical\" href=\"${escapeHtml(page.canonical)}\">` : \"\",\n meta(\"property\", \"og:type\", \"website\"),\n meta(\"property\", \"og:title\", title),\n meta(\"property\", \"og:description\", page.description),\n meta(\"property\", \"og:url\", page.canonical),\n ]\n .filter(Boolean)\n .join(\"\\n \");\n };\n\n const renderList = (page: ListPage) => {\n const items = page.posts\n .map((post) => {\n const postTags = post.tags.map(tagItem).join(\"\");\n return [\n '<li class=\"post-item\">',\n `<h2><a href=\"${escapeHtml(post.url)}\">${escapeHtml(post.title)}</a></h2>`,\n `<p class=\"post-meta\"><time datetime=\"${dateAttribute(post.date, post.dateHasTime)}\">${formatDate(post.date, post.dateHasTime)}</time> · ${post.readingMinutes} min read</p>`,\n `<p class=\"post-description\">${escapeHtml(post.description)}</p>`,\n postTags ? `<ul class=\"post-tags\">${postTags}</ul>` : \"\",\n \"</li>\",\n ]\n .filter(Boolean)\n .join(\"\");\n })\n .join(\"\\n\");\n const tagLinks =\n options.tagPages === false\n ? \"\"\n : tags\n .map((tag) => {\n const current = page.tag === tag ? ' aria-current=\"page\"' : \"\";\n return `<li><a href=\"${escapeHtml(tagUrl(tag))}\"${current}>${escapeHtml(content.tags[tag]?.name ?? tag)}</a></li>`;\n })\n .join(\"\");\n return [\n `<section class=\"post-list\" aria-labelledby=\"post-list-title\">`,\n `<h1 id=\"post-list-title\">${escapeHtml(page.title)}</h1>`,\n page.description\n ? `<p class=\"post-list-description\">${escapeHtml(page.description)}</p>`\n : \"\",\n tagLinks ? `<nav class=\"post-list-tags\" aria-label=\"Tags\"><ul>${tagLinks}</ul></nav>` : \"\",\n items\n ? `<ul class=\"post-items\">\\n${items}\\n</ul>`\n : '<p class=\"post-list-empty\">No posts yet.</p>',\n \"</section>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n };\n\n return {\n indexUrl,\n tagUrl,\n usedTags: tags,\n renderListHead,\n renderList,\n escapeHtml,\n formatDate,\n dateAttribute,\n renderToc,\n renderHead,\n renderArticle,\n tags: content.tags,\n posts: content.posts,\n };\n}\n\n/** Fills the page shell: head tags at `<!--blog:head-->` (or before `</head>`), the article at `<!--blog:content-->`. */\nexport function fillTemplate(template: string, head: string, article: string): string {\n const withHead = template.includes(HEAD_MARKER)\n ? template.replace(HEAD_MARKER, () => head)\n : template.replace(/<\\/head>/i, () => ` ${head}\\n </head>`);\n return withHead.replace(CONTENT_MARKER, () => article);\n}\n\nexport function renderPostPage(\n template: string,\n post: Post,\n options: ResolvedBlogOptions,\n helpers: RenderHelpers,\n): string {\n const head = options.render?.head?.(post, helpers) ?? helpers.renderHead(post);\n const article = options.render?.article?.(post, helpers) ?? helpers.renderArticle(post);\n return fillTemplate(template, head, article);\n}\n\nexport function renderListPage(\n template: string,\n page: ListPage,\n options: ResolvedBlogOptions,\n helpers: RenderHelpers,\n): string {\n const head = options.render?.listHead?.(page, helpers) ?? helpers.renderListHead(page);\n const body = options.render?.list?.(page, helpers) ?? helpers.renderList(page);\n return fillTemplate(template, head, body);\n}\n\n/** The data `virtual:blog/posts` exports: everything but the HTML. */\nexport function postSummaries(posts: Post[]) {\n return posts.map((post) => ({\n slug: post.slug,\n url: post.url,\n title: post.title,\n description: post.description,\n date: post.date.toISOString(),\n updated: post.updated?.toISOString(),\n tags: post.tags,\n authors: post.authors,\n featured: post.featured,\n series: post.series,\n readingMinutes: post.readingMinutes,\n data: post.data,\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IA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AQ,SAAS;AACvB,gBAAM,OAAO,MAAM,IAAI,QAAQ;AAC/B,cAAI,CAAC,MAAM;AAET,gBAAI,CAAC,SAAS,SAAS,GAAG,KAAK,MAAM,IAAI,GAAG,QAAQ,GAAG,GAAG;AACxD,kBAAI,aAAa;AACjB,kBAAI,UAAU,YAAY,GAAG,QAAQ,GAAG,QAAQ,IAAI,IAAI,MAAM,EAAE;AAChE,qBAAO,IAAI,IAAI;AAAA,YACjB;AACA,mBAAO,KAAK;AAAA,UACd;AACA,gBAAM,OAAO,MAAM,OAAO;AAAA,YACxB,GAAG,QAAQ;AAAA,YACX,WAAW,IAAI;AAAA,YACf,IAAI;AAAA,UACN;AACA,cAAI,UAAU,gBAAgB,0BAA0B;AACxD,cAAI,UAAU,iBAAiB,UAAU;AACzC,cAAI,IAAI,IAAI;AAAA,QACd,SAAS,OAAO;AACd,eAAK,KAAK;AAAA,QACZ;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["import_node_fs","import_node_path","import_node_fs","import_node_path","import_yaml","path","attr","path","attr","markdownIt","path","highlighter","md","usedTags","links","tags","path","module"]}
@@ -0,0 +1,232 @@
1
+ import { Plugin } from 'vite';
2
+ import { MarkdownIt } from 'markdown-it';
3
+
4
+ /** A tag a post may use, from the `tags` option or `tags.yml`. */
5
+ interface TagInfo {
6
+ name: string;
7
+ description?: string;
8
+ }
9
+ /** A post's author, from the `authors` option or `authors.yml`. */
10
+ interface AuthorInfo {
11
+ name: string;
12
+ url?: string;
13
+ }
14
+ /** A `##` or `###` heading, for a table of contents. */
15
+ interface TocEntry {
16
+ level: 2 | 3;
17
+ id: string;
18
+ /** The heading as plain text. */
19
+ text: string;
20
+ }
21
+ /** A post as read from its Markdown file, before rendering. */
22
+ interface PostSource {
23
+ /** From the folder (`posts/vpn-leaks/index.md`) or file name (`posts/vpn-leaks.md`). */
24
+ slug: string;
25
+ /** Absolute path of the Markdown file. */
26
+ file: string;
27
+ /** Front matter, as written. */
28
+ data: Record<string, unknown>;
29
+ /** Markdown after the front matter. */
30
+ content: string;
31
+ }
32
+ /** A rendered post. */
33
+ interface Post {
34
+ slug: string;
35
+ /** Path on the site, with Vite's `base`: `/blog/vpn-leaks/`. */
36
+ url: string;
37
+ /** Absolute URL, when the `site` option is set. */
38
+ canonical?: string;
39
+ file: string;
40
+ title: string;
41
+ description: string;
42
+ date: Date;
43
+ /** Whether the front matter gave a time, so a date alone is never shown with "12:00 AM". */
44
+ dateHasTime: boolean;
45
+ updated?: Date;
46
+ tags: string[];
47
+ authors: AuthorInfo[];
48
+ draft: boolean;
49
+ /** Dated after the build's `now`. Only built with `preview`. */
50
+ scheduled: boolean;
51
+ featured: boolean;
52
+ series?: string;
53
+ /** The cover image's URL, as the page should reference it. */
54
+ cover?: string;
55
+ /** Front matter, as written, including fields this plugin doesn't know (`tools`, `discuss`). */
56
+ data: Record<string, unknown>;
57
+ /** The article body as HTML. */
58
+ html: string;
59
+ toc: TocEntry[];
60
+ readingMinutes: number;
61
+ words: number;
62
+ }
63
+ /** Context a directive renders with. */
64
+ interface DirectiveContext {
65
+ /** Everything after the directive's name on its opening line, trimmed. */
66
+ args: string;
67
+ /** A container's body, rendered to HTML. `''` for a leaf directive. */
68
+ body: string;
69
+ post: PostSource;
70
+ md: MarkdownIt;
71
+ /** Fails the build (or shows the error page in dev), naming the post. */
72
+ error(message: string): void;
73
+ }
74
+ /**
75
+ * A `:::` block. A **leaf** directive is one line (`::: tool check example.com`).
76
+ * A **container** wraps Markdown until a line holding only `:::`.
77
+ */
78
+ interface Directive {
79
+ kind: "leaf" | "container";
80
+ render(context: DirectiveContext): string;
81
+ }
82
+ /** The blog's index (`/blog/`) or one tag's page (`/blog/tag/dns/`). */
83
+ interface ListPage {
84
+ kind: "index" | "tag";
85
+ /** Path on the site, with Vite's `base`: `/blog/tag/dns/`. */
86
+ url: string;
87
+ /** Absolute URL, when the `site` option is set. */
88
+ canonical?: string;
89
+ title: string;
90
+ description: string;
91
+ /** The tag id, on a tag page. */
92
+ tag?: string;
93
+ /** The page's posts, newest first. */
94
+ posts: Post[];
95
+ }
96
+ /** Helpers passed to the page renderers. */
97
+ interface RenderHelpers {
98
+ /** The blog index's path: `/blog/`. */
99
+ indexUrl: string;
100
+ /** A tag page's path: `/blog/tag/dns/`. Tags without published posts have no page. */
101
+ tagUrl: (tag: string) => string;
102
+ /** Tags with at least one published post, by id, in `tags.yml` order. */
103
+ usedTags: string[];
104
+ /** The default `<head>` tags for the index or a tag page. */
105
+ renderListHead: (page: ListPage) => string;
106
+ /** The default markup for the index or a tag page. */
107
+ renderList: (page: ListPage) => string;
108
+ escapeHtml: (value: string) => string;
109
+ /** A post's date for readers, in the blog's locale and time zone. */
110
+ formatDate: (date: Date, hasTime?: boolean) => string;
111
+ /** A `<time datetime>` value. */
112
+ dateAttribute: (date: Date, hasTime?: boolean) => string;
113
+ /** A `<nav>` list of the headings, or `''` when there are fewer than two. */
114
+ renderToc: (toc: TocEntry[]) => string;
115
+ /** The default `<head>` tags for a post. */
116
+ renderHead: (post: Post) => string;
117
+ /** The default article markup for a post. */
118
+ renderArticle: (post: Post) => string;
119
+ tags: Record<string, TagInfo>;
120
+ /** Every published post, newest first. */
121
+ posts: Post[];
122
+ }
123
+ /** One problem with a post, reported by file. */
124
+ interface BlogIssue {
125
+ file: string;
126
+ message: string;
127
+ }
128
+ interface BlogOptions {
129
+ /**
130
+ * The content folder. It holds `posts/` (one folder or `.md` file per post),
131
+ * and optionally `tags.yml` and `authors.yml`. Relative to Vite's `root`.
132
+ */
133
+ dir: string;
134
+ /** Where the blog lives on the site. Default `/blog/`. */
135
+ base?: string;
136
+ /** The site's origin, `https://example.com`, for canonical URLs and Open Graph tags. */
137
+ site?: string;
138
+ /**
139
+ * The HTML page shell for posts, relative to Vite's `root`. It must contain
140
+ * `<!--blog:content-->`, and may contain `<!--blog:head-->` (otherwise the
141
+ * head tags go before `</head>`). Scripts and styles in it are bundled by
142
+ * Vite as in any other page.
143
+ */
144
+ template: string;
145
+ /** Include drafts and scheduled posts, with `noindex`. Default `false`. */
146
+ preview?: boolean;
147
+ /** What "now" is when deciding whether a post is scheduled. Default: the build's start. */
148
+ now?: Date;
149
+ /** IANA time zone for dates without an offset, and for showing dates. Default `UTC`. */
150
+ timeZone?: string;
151
+ /** For showing dates. Default `en-US`. */
152
+ locale?: string;
153
+ /** Default 230. */
154
+ wordsPerMinute?: number;
155
+ /** Added after the post title in `<title>`: `" · Example"`. Default `''`. */
156
+ titleSuffix?: string;
157
+ /** The blog index's heading and description. Default `{ title: "Blog", description: "" }`. */
158
+ index?: {
159
+ title?: string;
160
+ description?: string;
161
+ };
162
+ /** Write a page per tag at `{base}tag/{tag}/`. Default `true`. */
163
+ tagPages?: boolean;
164
+ /** Front matter limits. */
165
+ limits?: {
166
+ /** Longest title, in characters. Default 70. */
167
+ title?: number;
168
+ /** Longest description, in characters. Default 160. */
169
+ description?: number;
170
+ /** Fewest tags a post may have. Default 0. */
171
+ minTags?: number;
172
+ /** Most tags a post may have. Default no limit. */
173
+ maxTags?: number;
174
+ };
175
+ /**
176
+ * The only tags posts may use. Defaults to `tags.yml` in `dir`; without it,
177
+ * any tag is allowed.
178
+ */
179
+ tags?: Record<string, TagInfo>;
180
+ /** Known authors, by id. Defaults to `authors.yml` in `dir`. */
181
+ authors?: Record<string, AuthorInfo>;
182
+ /** `:::` directives. `note`, `tip` and `warning` callouts are built in; a directive here with the same name replaces one. */
183
+ directives?: Record<string, Directive>;
184
+ /** Code highlighting with Shiki, or `false` for plain `<pre>`. */
185
+ highlight?: false | {
186
+ /** Default `{ light: "github-light", dark: "github-dark" }`. */
187
+ themes?: {
188
+ light: string;
189
+ dark: string;
190
+ };
191
+ /** Prefix for the generated color classes. Default `sk-`. */
192
+ classPrefix?: string;
193
+ };
194
+ /** Change the markdown-it instance: add plugins, rules or options. */
195
+ markdown?: (md: MarkdownIt) => void;
196
+ /**
197
+ * Whether a link to a site page outside the blog points at a real page. Links
198
+ * between posts are always checked. Without this, other links aren't.
199
+ */
200
+ isKnownPath?: (path: string) => boolean;
201
+ /** Extra checks for a post. Return messages to fail the build. */
202
+ validate?: (post: Post) => string[] | void;
203
+ /** Replace the default markup. */
204
+ render?: {
205
+ /** Tags for `<!--blog:head-->`. */
206
+ head?: (post: Post, helpers: RenderHelpers) => string;
207
+ /** Markup for `<!--blog:content-->`. */
208
+ article?: (post: Post, helpers: RenderHelpers) => string;
209
+ /** Head tags for the index and tag pages. */
210
+ listHead?: (page: ListPage, helpers: RenderHelpers) => string;
211
+ /** Markup for the index and tag pages. */
212
+ list?: (page: ListPage, helpers: RenderHelpers) => string;
213
+ };
214
+ }
215
+
216
+ /**
217
+ * A static Markdown blog for a Vite site. Each post becomes an HTML page,
218
+ * built from the site's own page shell, so the site's scripts, styles and
219
+ * `transformIndexHtml` plugins apply to posts like to any other page.
220
+ */
221
+ declare function blog(userOptions: BlogOptions): Plugin;
222
+
223
+ /** `::: note`, `::: tip` and `::: warning`, with an optional title after the name. */
224
+ declare const BUILT_IN_DIRECTIVES: Record<string, Directive>;
225
+
226
+ /** Escapes the characters that are special in HTML text and attribute values. */
227
+ declare function escapeHtml(value: string): string;
228
+ /** Lowercase words joined by hyphens: "Is your VPN working?" is `is-your-vpn-working`. */
229
+ declare function slugify(text: string): string;
230
+
231
+ export { BUILT_IN_DIRECTIVES, blog, blog as default, escapeHtml, slugify };
232
+ export type { AuthorInfo, BlogIssue, BlogOptions, Directive, DirectiveContext, ListPage, Post, PostSource, RenderHelpers, TagInfo, TocEntry };