File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { rehypeHandleMdExtension } from "./rehype-plugin";
88// https://astro.build/config
99export default defineConfig ( {
1010 markdown : {
11- rehypePlugins : [ rehypeHandleMdExtension ]
11+ rehypePlugins : [ rehypeHandleMdExtension ] ,
1212 } ,
1313 integrations : [
1414 react ( ) ,
Original file line number Diff line number Diff line change 11import { visit } from "unist-util-visit" ;
22
33export const rehypeHandleMdExtension = ( ) => {
4- const pattern = / ^ ( \. .+ ) \. m d ( .* ) / ;
4+ const pattern = / ^ ( \. .+ ) \. m d ( .* ) / ;
55
6- const canBeProcessed = ( node ) => (
7- node . tagName === "a" &&
8- node . properties . href &&
9- pattern . test ( node . properties . href )
10- )
6+ const canBeProcessed = ( node ) =>
7+ node . tagName === "a" &&
8+ node . properties . href &&
9+ pattern . test ( node . properties . href ) ;
1110
12- const processNode = ( node ) => {
13- const href = node . properties . href ;
14- const results = href . match ( pattern )
15- node . properties . href = `${ results [ 1 ] } ${ results [ 2 ] } ` ;
16- }
11+ const processNode = ( node ) => {
12+ const href = node . properties . href ;
13+ const results = href . match ( pattern ) ;
14+ node . properties . href = `${ results [ 1 ] } ${ results [ 2 ] } ` ;
15+ } ;
1716
18- return ( tree ) => {
19- visit ( tree , "element" , ( node ) => {
20- canBeProcessed ( node ) && processNode ( node )
21- } )
22- }
23- }
17+ return ( tree ) => {
18+ visit ( tree , "element" , ( node ) => {
19+ canBeProcessed ( node ) && processNode ( node ) ;
20+ } ) ;
21+ } ;
22+ } ;
You can’t perform that action at this time.
0 commit comments