2024-09-04 21:16:37 +00:00
|
|
|
import { defineConfig } from "astro/config";
|
2026-04-22 17:53:21 +00:00
|
|
|
import { globbySync } from "globby";
|
|
|
|
|
import fs from "node:fs";
|
|
|
|
|
import matter from "gray-matter";
|
|
|
|
|
import path from "node:path";
|
|
|
|
|
import rehypeExternalLinks from "rehype-external-links";
|
|
|
|
|
import sitemap from "@astrojs/sitemap";
|
|
|
|
|
|
2024-09-06 08:21:27 +00:00
|
|
|
import { remarkReadingTime } from "./src/plugins/remarkReadingTime";
|
2025-06-14 19:25:16 +00:00
|
|
|
import ogImages from "./src/integrations/ogImages";
|
2026-04-22 17:53:21 +00:00
|
|
|
import rehypeLazyImages from "./src/plugins/rehypeLazyImages";
|
|
|
|
|
|
|
|
|
|
const blogDir = path.resolve("./src/content/blog");
|
|
|
|
|
|
|
|
|
|
const lastmodBySlug = Object.fromEntries(
|
|
|
|
|
globbySync("*.md", { cwd: blogDir }).map((file) => {
|
|
|
|
|
const slug = file.replace(/\.md$/, "");
|
|
|
|
|
const { data } = matter(fs.readFileSync(path.join(blogDir, file), "utf8"));
|
|
|
|
|
const date = data.dateModified ?? data.datePublished;
|
|
|
|
|
return [slug, new Date(date).toISOString()];
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const buildLastmod = new Date().toISOString();
|
2024-09-04 21:16:37 +00:00
|
|
|
|
2024-09-04 21:23:21 +00:00
|
|
|
export default defineConfig({
|
|
|
|
|
site: "https://popov.link",
|
2024-10-24 19:54:32 +00:00
|
|
|
output: "static",
|
2026-04-22 17:53:21 +00:00
|
|
|
integrations: [
|
|
|
|
|
sitemap({
|
|
|
|
|
serialize(item) {
|
|
|
|
|
const url = new URL(item.url);
|
|
|
|
|
const match = url.pathname.match(/^\/blog\/([^/]+)\/?$/);
|
|
|
|
|
|
|
|
|
|
if (match && lastmodBySlug[match[1]]) {
|
|
|
|
|
item.lastmod = lastmodBySlug[match[1]];
|
|
|
|
|
} else {
|
|
|
|
|
item.lastmod = buildLastmod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
ogImages(),
|
|
|
|
|
],
|
2024-09-18 00:41:02 +00:00
|
|
|
build: {
|
|
|
|
|
inlineStylesheets: "always",
|
|
|
|
|
},
|
2024-09-06 08:21:27 +00:00
|
|
|
markdown: {
|
|
|
|
|
remarkPlugins: [remarkReadingTime],
|
2026-04-22 17:53:21 +00:00
|
|
|
rehypePlugins: [[rehypeExternalLinks, { target: "_blank", rel: ["noopener", "noreferrer"] }], rehypeLazyImages],
|
2025-01-23 23:03:20 +00:00
|
|
|
shikiConfig: {
|
|
|
|
|
theme: "vitesse-dark",
|
|
|
|
|
},
|
2024-09-06 08:21:27 +00:00
|
|
|
},
|
2024-09-04 21:23:21 +00:00
|
|
|
});
|