@@ -2,6 +2,28 @@ import { defineConfig } from 'astro/config';
22import mdx from '@astrojs/mdx' ;
33import sitemap from '@astrojs/sitemap' ;
44import tailwind from '@astrojs/tailwind' ;
5+ import remarkDirective from 'remark-directive' ;
6+ import { visit } from 'unist-util-visit' ;
7+ import { h } from 'hastscript' ;
8+
9+ // Custom remark plugin to handle admonitions (:::tip:::, :::warning:::, etc.)
10+ function remarkAdmonitions ( ) {
11+ return ( tree ) => {
12+ visit ( tree , ( node ) => {
13+ if (
14+ node . type === 'textDirective' ||
15+ node . type === 'leafDirective' ||
16+ node . type === 'containerDirective'
17+ ) {
18+ const data = node . data || ( node . data = { } ) ;
19+ const tagName = node . type === 'textDirective' ? 'span' : 'div' ;
20+
21+ data . hName = tagName ;
22+ data . hProperties = h ( tagName , { class : `admonition admonition-${ node . name } ` } ) . properties ;
23+ }
24+ } ) ;
25+ } ;
26+ }
527
628// https://astro.build/config
729export default defineConfig ( {
@@ -21,13 +43,22 @@ export default defineConfig({
2143 } ) ,
2244 ] ,
2345 markdown : {
46+ remarkPlugins : [ remarkDirective , remarkAdmonitions ] ,
2447 shikiConfig : {
25- theme : 'github-dark' ,
2648 themes : {
2749 light : 'github-light' ,
28- dark : 'github-dark' ,
50+ dark : 'github-dark-dimmed ' ,
2951 } ,
3052 wrap : true ,
53+ transformers : [
54+ {
55+ name : 'add-copy-button' ,
56+ pre ( node ) {
57+ // Add a data attribute to enable copy button
58+ this . addClassToHast ( node , 'code-block-wrapper' ) ;
59+ } ,
60+ } ,
61+ ] ,
3162 } ,
3263 } ,
3364} ) ;
0 commit comments