121 lines
2.9 KiB
TypeScript
121 lines
2.9 KiB
TypeScript
import fs from "node:fs";
|
|
import mdx from "@astrojs/mdx";
|
|
import sitemap from "@astrojs/sitemap";
|
|
import tailwind from "@astrojs/tailwind";
|
|
import expressiveCode from "astro-expressive-code";
|
|
import icon from "astro-icon";
|
|
import robotsTxt from "astro-robots-txt";
|
|
import webmanifest from "astro-webmanifest";
|
|
import { defineConfig } from "astro/config";
|
|
import { expressiveCodeOptions } from "./src/site.config";
|
|
import { siteConfig } from "./src/site.config";
|
|
|
|
// Remark plugins
|
|
import remarkDirective from "remark-directive"; /* Handle ::: directives as nodes */
|
|
import remarkUnwrapImages from "remark-unwrap-images";
|
|
import { remarkAdmonitions } from "./src/plugins/remark-admonitions"; /* Add admonitions */
|
|
import { remarkReadingTime } from "./src/plugins/remark-reading-time";
|
|
|
|
// Rehype plugins
|
|
import rehypeExternalLinks from "rehype-external-links";
|
|
|
|
// https://astro.build/config
|
|
export default defineConfig({
|
|
image: {
|
|
domains: ["webmention.io"],
|
|
},
|
|
integrations: [
|
|
expressiveCode(expressiveCodeOptions),
|
|
icon(),
|
|
tailwind({
|
|
applyBaseStyles: false,
|
|
nesting: true,
|
|
}),
|
|
sitemap(),
|
|
mdx(),
|
|
robotsTxt(),
|
|
webmanifest({
|
|
// See: https://github.com/alextim/astro-lib/blob/main/packages/astro-webmanifest/README.md
|
|
/**
|
|
* required
|
|
**/
|
|
name: siteConfig.title,
|
|
/**
|
|
* optional
|
|
**/
|
|
// short_name: "Astro_Cactus",
|
|
description: siteConfig.description,
|
|
lang: siteConfig.lang,
|
|
icon: "public/icon.svg", // the source for generating favicon & icons
|
|
icons: [
|
|
{
|
|
src: "icons/apple-touch-icon.png", // used in src/components/BaseHead.astro L:26
|
|
sizes: "180x180",
|
|
type: "image/png",
|
|
},
|
|
{
|
|
src: "icons/icon-192.png",
|
|
sizes: "192x192",
|
|
type: "image/png",
|
|
},
|
|
{
|
|
src: "icons/icon-512.png",
|
|
sizes: "512x512",
|
|
type: "image/png",
|
|
},
|
|
],
|
|
start_url: "/",
|
|
background_color: "#1d1f21",
|
|
theme_color: "#2bbc8a",
|
|
display: "standalone",
|
|
config: {
|
|
insertFaviconLinks: false,
|
|
insertThemeColorMeta: false,
|
|
insertManifestLink: false,
|
|
},
|
|
}),
|
|
],
|
|
markdown: {
|
|
rehypePlugins: [
|
|
[
|
|
rehypeExternalLinks,
|
|
{
|
|
rel: ["nofollow, noreferrer"],
|
|
target: "_blank",
|
|
},
|
|
],
|
|
],
|
|
remarkPlugins: [remarkUnwrapImages, remarkReadingTime, remarkDirective, remarkAdmonitions],
|
|
remarkRehype: {
|
|
footnoteLabelProperties: {
|
|
className: [""],
|
|
},
|
|
},
|
|
},
|
|
// https://docs.astro.build/en/guides/prefetch/
|
|
prefetch: true,
|
|
// ! Please remember to replace the following site property with your own domain
|
|
site: "https://lio.cat/",
|
|
vite: {
|
|
optimizeDeps: {
|
|
exclude: ["@resvg/resvg-js"],
|
|
},
|
|
plugins: [rawFonts([".ttf", ".woff"])],
|
|
},
|
|
});
|
|
|
|
function rawFonts(ext: string[]) {
|
|
return {
|
|
name: "vite-plugin-raw-fonts",
|
|
// @ts-expect-error:next-line
|
|
transform(_, id) {
|
|
if (ext.some((e) => id.endsWith(e))) {
|
|
const buffer = fs.readFileSync(id);
|
|
return {
|
|
code: `export default ${JSON.stringify(buffer)}`,
|
|
map: null,
|
|
};
|
|
}
|
|
},
|
|
};
|
|
}
|