build: bump astro to 3.4

This commit is contained in:
Maciej Jur 2023-10-28 16:58:58 +02:00
parent 56261f3379
commit 7b63588fcc
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
6 changed files with 1278 additions and 814 deletions

View file

@ -1,34 +1,39 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import rehypeKatex from 'rehype-katex'; import mdx from '@astrojs/mdx';
import remarkMath from 'remark-math'; import solid from '@astrojs/solid-js';
import remarkEmoji from 'remark-emoji'; import pagefind from 'astro-pagefind';
import mdx from '@astrojs/mdx'; import remarkDirective from 'remark-directive';
import solid from '@astrojs/solid-js'; import remarkMath from 'remark-math';
import pagefind from 'astro-pagefind'; import rehypeKatex from 'rehype-katex';
import remarkDirective from 'remark-directive'; import remarkEmoji from 'remark-emoji';
import remarkBibliography from "./src/utils/remark/bibliography"; import remarkBib from './src/utils/remark/bib';
import remarkRuby from "./src/utils/remark/ruby"; import remarkRuby from './src/utils/remark/ruby';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
site: 'https://kamoshi.org', site: 'https://kamoshi.org',
trailingSlash: 'always', trailingSlash: 'always',
compressHTML: true,
markdown: { markdown: {
remarkPlugins: [ remarkPlugins: [
// NOTE: pinned ^2.0.0
remarkDirective, remarkDirective,
[remarkRuby, {separator: ';'}], // NOTE: pinned ^5.0.0
remarkBibliography,
[remarkEmoji, {accessible: true}],
remarkMath, remarkMath,
remarkEmoji,
[remarkRuby, {sep: ';'}],
remarkBib,
], ],
rehypePlugins: [ rehypePlugins: [
[rehypeKatex, {output: 'mathml'}] // https://katex.org/docs/options.html
[rehypeKatex, {output: 'mathml'}],
], ],
shikiConfig: { shikiConfig: {
theme: 'min-light' theme: 'min-light'
} },
},
experimental: {
devOverlay: true,
}, },
integrations: [ integrations: [
mdx(), mdx(),

View file

@ -11,40 +11,40 @@
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"@astrojs/mdx": "^1.0.3", "@astrojs/mdx": "^1.1.3",
"@astrojs/solid-js": "^3.0.1", "@astrojs/solid-js": "^3.0.2",
"@citation-js/plugin-bibtex": "^0.6.8", "@citation-js/plugin-bibtex": "^0.7.2",
"@js-temporal/polyfill": "^0.4.4", "@js-temporal/polyfill": "^0.4.4",
"astro": "^3.0.12", "astro": "^3.4.0",
"astro-pagefind": "^1.2.3", "astro-pagefind": "^1.3.0",
"chart.js": "^4.4.0", "chart.js": "^4.4.0",
"citation-js": "^0.6.8", "citation-js": "^0.7.1",
"dayjs": "^1.11.9", "dayjs": "^1.11.10",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3", "leaflet.markercluster": "^1.5.3",
"mdast-util-to-string": "^4.0.0", "mdast-util-to-string": "^4.0.0",
"purify-ts": "^2.0.1", "purify-ts": "^2.0.1",
"rehype-katex": "^6.0.3", "rehype-katex": "^7.0.0",
"rehype-raw": "^7.0.0", "rehype-raw": "^7.0.0",
"rehype-stringify": "^10.0.0", "rehype-stringify": "^10.0.0",
"remark-directive": "^2.0.1", "remark-directive": "^2.0.0",
"remark-emoji": "^4.0.0", "remark-emoji": "^4.0.0",
"remark-gfm": "^3.0.1", "remark-gfm": "^4.0.0",
"remark-math": "^5.1.1", "remark-math": "^5.0.0",
"remark-parse": "^10.0.2", "remark-parse": "^11.0.0",
"remark-rehype": "^10.1.0", "remark-rehype": "^11.0.0",
"reveal.js": "^4.5.0", "reveal.js": "^5.0.0",
"solid-js": "^1.7.11", "solid-js": "^1.8.4",
"unified": "^11.0.3", "unified": "^11.0.4",
"unist-util-visit": "^5.0.0" "unist-util-visit": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/leaflet": "^1.9.4", "@types/leaflet": "^1.9.7",
"@types/leaflet.markercluster": "^1.5.2", "@types/leaflet.markercluster": "^1.5.3",
"@types/reveal.js": "^4.4.2", "@types/reveal.js": "^4.4.5",
"@types/unist": "^3.0.0", "@types/unist": "^3.0.1",
"pagefind": "^0.12.0", "pagefind": "^1.0.3",
"sass": "^1.66.1", "sass": "^1.69.5",
"sharp": "^0.32.5" "sharp": "^0.32.6"
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -28,12 +28,13 @@ interface PagefindDocument {
word_count: number; word_count: number;
} }
const enum PagefindModule {
async function loadPagefind(): Promise<Pagefind> { LINK = '/pagefind/pagefind.js',
const pf = "/_pagefind/pagefind.js";
return await import(/* @vite-ignore */ pf);
} }
const loadPagefind = () => import(/* @vite-ignore */PagefindModule.LINK) as Promise<Pagefind>;
function Result(props: { page: PagefindResult }) { function Result(props: { page: PagefindResult }) {
const [data, setData] = createSignal<PagefindDocument>(); const [data, setData] = createSignal<PagefindDocument>();
@ -53,7 +54,6 @@ function Result(props: { page: PagefindResult }) {
<div>Loading...</div> <div>Loading...</div>
)} )}
</> </>
) )
} }

View file

@ -1,8 +1,6 @@
import "@citation-js/plugin-bibtex"; import "@citation-js/plugin-bibtex";
// @ts-ignore // @ts-ignore
import Cite from "citation-js"; import Cite from "citation-js";
import type { Root } from "remark-directive";
import type { Plugin } from "unified";
import { visit, EXIT, CONTINUE } from "unist-util-visit"; import { visit, EXIT, CONTINUE } from "unist-util-visit";
import { toString } from "mdast-util-to-string"; import { toString } from "mdast-util-to-string";
import { Maybe } from "purify-ts"; import { Maybe } from "purify-ts";
@ -11,8 +9,8 @@ import { Maybe } from "purify-ts";
function locateBibliography(tree: any) { function locateBibliography(tree: any) {
let bibliography: Maybe<Cite> = Maybe.empty(); let bibliography: Maybe<Cite> = Maybe.empty();
visit(tree, "containerDirective", (node, index, parent) => { visit(tree, 'containerDirective', (node, index, parent) => {
if (node.name !== "bib") if (node.name !== 'bib')
return CONTINUE; return CONTINUE;
const data = new Cite(toString(node)); const data = new Cite(toString(node));
@ -57,11 +55,9 @@ function convertCitations(tree: any, data: Cite) {
} }
export const remarkBibliography: Plugin<[], Root> = (options?: any) => { export default function remarkBibliography(options?: any) {
return (tree: any) => { return (tree: any) => {
locateBibliography(tree) locateBibliography(tree)
.ifJust(data => convertCitations(tree, data)); .ifJust(data => convertCitations(tree, data));
} }
} }
export default remarkBibliography;

View file

@ -5,7 +5,7 @@ import { toString } from "mdast-util-to-string";
interface Options { interface Options {
separator: string; sep: string;
} }
type Pair = [string, string]; type Pair = [string, string];
@ -17,7 +17,7 @@ function toHtml([text, help]: Pair) {
function createRuby(text: string, help: string, options?: Options) { function createRuby(text: string, help: string, options?: Options) {
const splitText = text.split(''); const splitText = text.split('');
const splitHelp = help.split(options?.separator || ';'); const splitHelp = help.split(options?.sep || ';');
const pairs = (splitText.length === splitHelp.length) const pairs = (splitText.length === splitHelp.length)
? splitText.map((e, i) => [e, splitHelp[i]] as Pair) ? splitText.map((e, i) => [e, splitHelp[i]] as Pair)
@ -27,7 +27,7 @@ function createRuby(text: string, help: string, options?: Options) {
} }
export const remarkRuby: Plugin<[Options?], Root> = (options?: Options) => { export default function remarkRuby(options?: Options) {
return (tree: any) => { return (tree: any) => {
visit(tree, "textDirective", (node, index, parent) => { visit(tree, "textDirective", (node, index, parent) => {
if (node.name !== 'ruby') if (node.name !== 'ruby')
@ -46,5 +46,3 @@ export const remarkRuby: Plugin<[Options?], Root> = (options?: Options) => {
}) })
} }
} }
export default remarkRuby;