-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
86 lines (71 loc) · 2.87 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import getReadingTime from 'reading-time';
import { toString } from 'mdast-util-to-string';
import { toc } from 'mdast-util-toc'
import { rehypeHeadingIds } from '@astrojs/markdown-remark';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import { defineConfig } from 'astro/config';
// https://docs.astro.build/en/guides/integrations-guide/mdx/
import mdx from '@astrojs/mdx';
// https://docs.astro.build/en/guides/integrations-guide/tailwind/
import tailwind from '@astrojs/tailwind';
// https://docs.astro.build/en/guides/integrations-guide/sitemap/
// See `site` field below
import sitemap from '@astrojs/sitemap';
// https://github.com/alextim/astro-lib/tree/main/packages/astro-robots-txt#installation
import robotsTxt from 'astro-robots-txt';
// https://astro.build/config
export default defineConfig({
// https://docs.astro.build/en/reference/configuration-reference/#site
site: 'https://acuarica.github.io',
// https://docs.astro.build/en/reference/configuration-reference/#base
// base: '/dev',
markdown: {
remarkPlugins: [
remarkToc,
remarkReadingTime,
remarkPreviewParagraph,
],
rehypePlugins: [
rehypeHeadingIds,
// https://github.com/rehypejs/rehype-autolink-headings#api
rehypeAutolinkHeadings,
]
},
// https://docs.astro.build/en/reference/configuration-reference/#integrations
integrations: [
mdx(),
tailwind(),
// https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview
sitemap({
// https://docs.astro.build/en/guides/integrations-guide/sitemap/#changefreq-lastmod-and-priority
// > Note that changefreq and priority are ignored by Google.
changefreq: 'weekly',
// priority: 0.7,
lastmod: new Date(),
}),
// Allow all bots to scan and index your site.
// Full syntax: https://developers.google.com/search/docs/advanced/robots/create-robots-txt
robotsTxt(),
],
});
function remarkToc() {
return function (tree, { data }) {
data.astro.frontmatter.toc = toc(tree);
};
}
// https://docs.astro.build/en/guides/markdown-content/#example-calculate-reading-time
// https://docs.astro.build/en/guides/content-collections/#modifying-frontmatter-with-remark
function remarkReadingTime() {
return function (tree, { data }) {
const textOnPage = toString(tree);
const readingTime = getReadingTime(textOnPage);
// readingTime.text will give us minutes read as a friendly string, i.e. "3 min read"
data.astro.frontmatter.minutesRead = readingTime.text;
};
}
function remarkPreviewParagraph() {
return function (tree, { data }) {
const textOnPage = toString(tree);
data.astro.frontmatter.previewParagraph = textOnPage.substring(0, 250);
};
}