@@ -7,12 +7,10 @@ import expressiveCode from 'astro-expressive-code';
7
7
import icon from 'astro-icon' ;
8
8
import { defineConfig } from 'astro/config' ;
9
9
import fontCarrier from 'font-carrier' ;
10
-
11
10
// Others
12
11
// import { visualizer } from 'rollup-plugin-visualizer'
13
- import rehypeCallouts from 'rehype-callouts' ;
14
- import rehypeKatex from 'rehype-katex' ;
15
- import remarkBreaks from 'remark-breaks' ;
12
+ import rehypeKatex from 'rehype-katex'
13
+ import remarkBreaks from 'remark-breaks'
16
14
import remarkMath from 'remark-math' ;
17
15
18
16
import AstroPureIntegration from './packages/pure/index.ts' ;
@@ -23,10 +21,30 @@ import { remarkAiNotice } from './src/plugins/remark-ai-notice.mjs';
23
21
import { remarkMermaid } from './src/plugins/remark-mermaid' ;
24
22
import config from './src/site.config.ts' ;
25
23
24
+
26
25
const createFontSubsetIntegration = ( ) => {
27
26
return {
28
27
name : 'font-subset-integration' ,
29
28
hooks : {
29
+ 'astro:server:start' : ( ) => {
30
+ const projectRoot = process . cwd ( ) ;
31
+ const fontPath = path . join ( projectRoot , 'src' , 'assets' , 'fonts' , 'crjk03w03.ttf' ) ;
32
+ const outputDir = path . join ( projectRoot , 'public' , 'fonts' ) ;
33
+ const outputPath = path . join ( outputDir , 'crjk-subset.ttf' ) ;
34
+
35
+ // To avoid slow startup, only copy the .ttf file in dev mode if it doesn't exist.
36
+ // The browser will show 404s for woff/woff2 but will fall back to the ttf.
37
+ if ( fs . existsSync ( outputPath ) ) {
38
+ return ;
39
+ }
40
+
41
+ if ( ! fs . existsSync ( outputDir ) ) {
42
+ fs . mkdirSync ( outputDir , { recursive : true } ) ;
43
+ }
44
+
45
+ fs . copyFileSync ( fontPath , outputPath ) ;
46
+ console . log ( 'Development font .ttf copied to public/fonts!' ) ;
47
+ } ,
30
48
'astro:build:done' : async ( { dir } ) => {
31
49
const projectRoot = process . cwd ( ) ;
32
50
const contentDir = path . join ( projectRoot , 'src' , 'content' ) ;
@@ -187,14 +205,6 @@ export default defineConfig({
187
205
content : { type : 'text' , value : '#' }
188
206
}
189
207
] ,
190
- [
191
- rehypeCallouts ,
192
- {
193
- props : {
194
- containerProps : { class : [ 'callout' , 'not-prose' ] }
195
- }
196
- }
197
- ]
198
208
]
199
209
} ,
200
210
experimental : {
0 commit comments