noway.moe/astro.config.mjs

80 lines
3 KiB
JavaScript
Raw Normal View History

2023-12-25 22:27:19 -07:00
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
2023-12-25 23:43:02 -07:00
//import cloudflare from "@astrojs/cloudflare";
import remarkGfm from "remark-gfm";
import remarkRehype from "remark-rehype";
2023-12-28 00:37:59 -07:00
import rehypeSlug from "rehype-slug";
2023-12-26 03:45:47 -07:00
import rehypePrettyCode from "rehype-pretty-code";
2023-12-28 00:37:59 -07:00
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import { s } from "hastscript";
2023-12-26 03:46:58 -07:00
import json from "./public/themes/github_light.json" assert { type: "json" };
2023-12-25 22:27:19 -07:00
import tailwind from "@astrojs/tailwind";
2023-12-26 03:45:47 -07:00
const options = {
// Specify the theme to use or a custom theme json, in our case
// it will be a moonlight-II theme from
// https://github.com/atomiks/moonlight-vscode-theme/blob/master/src/moonlight-ii.json
theme: json,
// Callbacks to customize the output of the nodes
onVisitLine(node) {
// Prevent lines from collapsing in `display: grid` mode, and
// allow empty lines to be copy/pasted
if (node.children.length === 0) {
node.children = [{type: 'text', value: ' '}];
}
},
onVisitHighlightedLine(node) {
// Adding a class to the highlighted line
node.properties.className.push('highlighted');
},
};
2023-12-25 22:27:19 -07:00
// https://astro.build/config
export default defineConfig({
2023-12-25 23:43:02 -07:00
site: 'https://dev.noway.moe',
output: "static",
2023-12-25 22:27:19 -07:00
integrations: [mdx(), sitemap(), tailwind()],
2023-12-25 23:43:02 -07:00
build: {
format: "file",
inlineStylesheets: "auto",
},
markdown: {
2023-12-26 03:45:47 -07:00
gfm: true,
syntaxHighlight: false,
2023-12-25 23:43:02 -07:00
remarkPlugins: [
remarkGfm,
2023-12-28 00:37:59 -07:00
/* Conerts remark to rehype (md -> html) */
2023-12-25 23:43:02 -07:00
[remarkRehype, { clobberPrefix: "" }],
2023-12-28 00:37:59 -07:00
/*
* rehypeSlug adds IDs to headings... which rehypeAutolinkHeadings then
* extends to <a> tags
*/
[rehypeSlug, {}],
[rehypeAutolinkHeadings, {
content(node) {
return [
s('svg', {viewBox: "0 0 16 16", class: "icon-link", width: "16", height: "16"}, [
s('path', {d: "m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"})
])
]
}
}],
/* Does the syntax highlighting and parsing on code */
2023-12-26 03:45:47 -07:00
[rehypePrettyCode, options],
2023-12-25 23:43:02 -07:00
],
2023-12-26 03:45:47 -07:00
//shikiConfig: {
// // Choose from Shiki's built-in themes (or add your own)
// // https://github.com/shikijs/shiki/blob/main/docs/themes.md
// theme: 'dracula',
// // Add custom languages
// // Note: Shiki has countless langs built-in, including .astro!
// // https://github.com/shikijs/shiki/blob/main/docs/languages.md
// langs: ["c", "ssh-config"],
// // Enable word wrap to prevent horizontal scrolling
// wrap: true,
//},
2023-12-25 23:43:02 -07:00
}
});