-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
42 lines (40 loc) · 1.38 KB
/
astro.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { defineConfig } from "astro/config";
import icon from "astro-icon";
import mdx from "@astrojs/mdx";
import rehypePrettyCode from "rehype-pretty-code";
import { transformerCopyButton } from "@rehype-pretty/transformers";
import getReadingTime from "reading-time";
import { toString } from "mdast-util-to-string";
import rehypeSlug from "rehype-slug";
import rehypeAutoLinkHeadings from "rehype-autolink-headings";
export function remarkReadingTime() {
return function (tree, { data }) {
const textOnPage = toString(tree);
const readingTime = getReadingTime(textOnPage, { wordsPerMinute: 100 });
data.astro.frontmatter.minutesRead = readingTime.text;
};
}
export default defineConfig({
markdown: {
syntaxHighlight: false,
remarkPlugins: [remarkReadingTime],
rehypePlugins: [
[
rehypePrettyCode,
{
theme: "github-dark-default",
keepBackground: false,
transformers: [
transformerCopyButton({
visibility: "hover",
feedbackDuration: 1_000,
}),
],
},
],
rehypeSlug,
[rehypeAutoLinkHeadings, { behavior: "wrap" }],
],
},
integrations: [icon(), mdx()],
});