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-30 15:36:25 +03:00
|
|
|
import browserslist from 'browserslist'
|
|
|
|
import { browserslistToTargets } from 'lightningcss'
|
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-30 15:36:25 +03:00
|
|
|
css: {
|
|
|
|
transformer: 'lightningcss',
|
|
|
|
lightningcss: {
|
|
|
|
targets: browserslistToTargets(browserslist('>= 0.25%')),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
cssMinify: 'lightningcss',
|
|
|
|
},
|
2025-01-25 13:42:13 +03:00
|
|
|
},
|
|
|
|
adapter: node({
|
|
|
|
mode: 'standalone',
|
|
|
|
}),
|
|
|
|
server: {
|
|
|
|
host: true,
|
|
|
|
},
|
2024-08-03 06:30:05 +03:00
|
|
|
})
|