-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathastro.config.mjs
32 lines (30 loc) · 1.44 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
import { defineConfig } from 'astro/config'
import mdx from '@astrojs/mdx'
import sitemap from '@astrojs/sitemap'
import remarkBreaks from 'remark-breaks' // improves support for newlines in markdown files
import remarkGfm from 'remark-gfm' // support rendering tables in markdown files
// twitter & youtube auto-embed via remark
import remarkEmbedder from '@remark-embedder/core'
import oembedTransformer from '@remark-embedder/transformer-oembed'
const remarkEmbedPlugin = [remarkEmbedder.default, {
transformers: [oembedTransformer.default],
// https://github.com/remark-embedder/transformer-oembed/issues/25#issuecomment-888613740
// https://github.com/remark-embedder/core#handleerror-errorinfo-errorinfo--gottenhtml--promisegottenhtml
handleError ({error, url, transformer}) {
if (transformer.name !== '@remark-embedder/transformer-oembed' || !url.includes('twitter.com')) {
// we're only handling errors from this specific transformer and the twitter URL
// so we'll rethrow errors from any other transformer/url
throw error
}
console.error("ERROR: couldn't embed:", url)
return `<p style="color:red">ERROR: Unable to embed <a href="${url}">this tweet</a> (possibly deleted).</p>`
}
}]
// https://astro.build/config
export default defineConfig({
site: 'https://example.com', // CHANGE THIS TO YOUR HOMEPAGE!
integrations: [mdx(), sitemap()],
markdown: {
remarkPlugins: [remarkEmbedPlugin, remarkGfm, remarkBreaks]
}
})