tei.su/astro.config.mjs

73 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2024-08-03 06:30:05 +03:00
import node from '@astrojs/node'
2025-01-25 13:42:13 +03:00
import solid from '@astrojs/solid-js'
2025-01-26 19:00:11 +03:00
import { Graphviz } from '@hpcc-js/wasm-graphviz'
2025-01-25 13:42:13 +03:00
import { defineConfig } from 'astro/config'
2025-01-26 19:00:11 +03:00
import { toString } from 'mdast-util-to-string'
import getReadingTime from 'reading-time'
import { visit } from 'unist-util-visit'
2025-01-25 13:42:13 +03:00
import UnoCSS from 'unocss/astro'
2024-08-03 06:30:05 +03:00
2025-01-26 19:00:11 +03:00
function remarkReadingTime() {
return function (tree, { data }) {
const textOnPage = toString(tree)
const readingTime = getReadingTime(textOnPage)
data.astro.frontmatter.minutesRead = readingTime.text
}
}
function remarkGraphvizSvg() {
return async function (tree) {
const graphviz = await Graphviz.load()
const instances = []
visit(tree, { type: 'code', lang: 'dot' }, (node, index, parent) => {
instances.push([node.value, index, parent])
})
for (const [dot, index, parent] of instances) {
const svg = graphviz.dot(dot, 'svg')
parent.children.splice(index, 1, {
type: 'html',
value: `<div class="graphviz-svg">${svg}</div>`,
})
}
}
}
2024-08-03 06:30:05 +03:00
// https://astro.build/config
export default defineConfig({
2025-01-25 13:42:13 +03:00
output: 'server',
2025-01-26 19:00:11 +03:00
site: 'https://tei.su',
2025-01-25 13:42:13 +03:00
integrations: [
solid(),
UnoCSS({
injectReset: true,
2024-08-03 06:30:05 +03:00
}),
2025-01-25 13:42:13 +03:00
],
2025-01-26 19:00:11 +03:00
markdown: {
remarkPlugins: [
remarkReadingTime,
remarkGraphvizSvg,
],
smartypants: false,
shikiConfig: {
themes: {
dark: 'catppuccin-mocha',
light: 'catppuccin-latte',
},
},
},
2025-01-25 13:42:13 +03:00
vite: {
esbuild: { jsx: 'automatic' },
define: {
'import.meta.env.VITE_BUILD_DATE': JSON.stringify(new Date().toISOString().split('T')[0]),
2024-08-03 06:30:05 +03:00
},
2025-01-25 13:42:13 +03:00
},
adapter: node({
mode: 'standalone',
}),
server: {
host: true,
},
2024-08-03 06:30:05 +03:00
})