feat: Add astro config

We're basing this off the https://docs.astro.build/en/guides/markdown-content/#markdown-plugins
section of the astro docs, as well as some other remark information. We
have disabled XSS protection early in the rendering pipeline due to a
later sanitization step. This is mentioned on the remark docs and we have
tested it with some basic XSS examples
This commit is contained in:
Skyler Grey 2024-05-17 00:03:55 +00:00
parent a1e9459a60
commit 26b25a6cb6
Signed by: minion
GPG key ID: F27E3E5922772E7A

25
astro.config.mjs Normal file
View file

@ -0,0 +1,25 @@
import { defineConfig } from 'astro/config';
import rehypeSanitize from 'rehype-sanitize';
import rehypeStringify from 'rehype-stringify';
import rehypeRaw from 'rehype-raw';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
// https://astro.build/config
export default defineConfig({
markdown: {
remarkRehype: {
allowDangerousHtml: true
// This is fine because we are using rehypeSanitize to sanitize XSS.
// See https://github.com/remarkjs/remark-rehype?tab=readme-ov-file#example-supporting-html-in-markdown-properly
},
remarkPlugins: [
remarkParse,
remarkRehype,
rehypeRaw,
rehypeSanitize,
rehypeStringify,
]
}
});