feat: add GitHub repo card, admonitions (#77)

* Added remark-directive, unist-util-visit

* Add rehype custom components for Github, Admonitions

* pnpm

* Update pnpm-lock

* Corrected hastscript requierement

* Change ad- prefix so adblocks dont block content
This commit is contained in:
Fabrizio
2024-05-02 01:24:20 -03:00
committed by saicaca
parent 5e4ae01af6
commit e1dae88515
9 changed files with 6696 additions and 4724 deletions

View File

@@ -8,6 +8,11 @@ import rehypeKatex from "rehype-katex"
import rehypeSlug from "rehype-slug"
import remarkMath from "remark-math"
import { remarkReadingTime } from "./src/plugins/remark-reading-time.mjs"
import { GithubCardComponent } from "./src/plugins/rehype-component-github-card.mjs"
import { AdmonitionComponent } from "./src/plugins/rehype-component-admonition.mjs"
import remarkDirective from "remark-directive" /* Handle directives */
import remarkDirectiveRehype from 'remark-directive-rehype' /* Pass directives to rehype */
import rehypeComponents from "rehype-components"; /* Render the custom directive content */
import svelte from "@astrojs/svelte"
import swup from '@swup/astro';
import sitemap from '@astrojs/sitemap';
@@ -54,10 +59,20 @@ export default defineConfig({
sitemap(),
],
markdown: {
remarkPlugins: [remarkMath, remarkReadingTime],
remarkPlugins: [remarkMath, remarkReadingTime, remarkDirective, remarkDirectiveRehype],
rehypePlugins: [
rehypeKatex,
rehypeSlug,
[rehypeComponents, {
components: {
github: GithubCardComponent,
tip: (x, y) => AdmonitionComponent(x, y, "tip"),
note: (x, y) => AdmonitionComponent(x, y, "note"),
important: (x, y) => AdmonitionComponent(x, y, "important"),
caution: (x, y) => AdmonitionComponent(x, y, "caution"),
warning: (x, y) => AdmonitionComponent(x, y, "warning"),
},
}],
[
rehypeAutolinkHeadings,
{