@@ -7,29 +7,29 @@ import { slugify } from "../util/slugify.js";
77
88function replaceNoteUrl (
99 noteContent : string ,
10- urlToFileName : Record < string , string >
10+ urlToFileName : Record < string , string > ,
1111) {
1212 let result = noteContent ;
1313 Object . entries ( urlToFileName ) . forEach ( ( [ url , fileName ] ) => {
1414 result = result . replaceAll (
1515 new RegExp ( String . raw `\[([^\]]+)\]\(${ url } (#[^)]+)?\)` , "g" ) ,
16- `<a href="{% post_path ${ fileName } %}$2">$1</a>`
16+ `<a href="{% post_path ${ fileName } %}$2">$1</a>` ,
1717 ) ;
1818 } ) ;
1919 return result ;
2020}
2121
2222const rawNotes : Note [ ] = JSON . parse (
23- readFileSync ( "./res/hackmd-note-data.json" , { encoding : "utf8" } )
23+ readFileSync ( "./res/hackmd-note-data.json" , { encoding : "utf8" } ) ,
2424) ;
2525const noteTableData : NoteTableEntry [ ] = JSON . parse (
26- readFileSync ( "./res/note-table-data.json" , { encoding : "utf8" } )
26+ readFileSync ( "./res/note-table-data.json" , { encoding : "utf8" } ) ,
2727) ;
2828const notes = rawNotes . filter (
2929 ( n ) =>
3030 ! / ^ [ \w \- , ' ( ) ] + $ / . exec ( n . title ) &&
3131 n . title !== "Tangent 的 CharaChorder 和 Forge 筆記本" &&
32- n . title !== "Tangent 的 CharaChorder 和 Forge 筆記清單"
32+ n . title !== "Tangent 的 CharaChorder 和 Forge 筆記清單" ,
3333) ;
3434const urlToFileName : Record < string , string > = { } ;
3535for ( const note of rawNotes ) {
@@ -44,14 +44,14 @@ for (const note of notes) {
4444 const $ = cheerio . load ( html ) ;
4545 const description = $ ( 'meta[name="description"]' ) . attr ( "content" ) || "" ;
4646 const noteTableEntry = noteTableData . find ( ( entry ) =>
47- entry . zhTwNoteUrl . endsWith ( url )
47+ entry . zhTwNoteUrl . endsWith ( url ) ,
4848 ) ;
4949 if ( ! noteTableEntry ) {
5050 console . warn ( `No note table entry found for note: ${ note . title } ` ) ;
5151 continue ;
5252 }
5353 const enNote = rawNotes . find (
54- ( n ) => n . publishLink === noteTableEntry . enNoteUrl
54+ ( n ) => n . publishLink === noteTableEntry . enNoteUrl ,
5555 ) ;
5656 if ( ! enNote ) {
5757 console . warn ( `No en note found for note: ${ note . title } ` ) ;
@@ -70,12 +70,12 @@ ${[-2, -1, 0, 1, 2]
7070 ( offset ) =>
7171 moment ( note . createdAt ) . add ( offset , "days" ) . format ( " - /YYYY/MM/DD/" ) +
7272 fileName +
73- "/"
73+ "/" ,
7474 )
7575 . join ( "\n" ) }
7676otherLanguages:
7777 - text: English Version
78- path: https://andy23512.com /blog/${
78+ path: https://andy23512.github.io /blog/${
7979 urlToFileName [ noteTableEntry . enNoteUrl . replace ( "https://hackmd.io" , "" ) ]
8080 } /
8181---
@@ -89,18 +89,18 @@ ${replaceNoteUrl(
8989 . replaceAll ( "\n# " , "\n## " )
9090 . replaceAll (
9191 / : : : s p o i l e r ( .* ) \n ( [ \S \s ] * ?) : : : / g,
92- '{% collapsecard "$1" %}$2{% endcollapsecard %}'
92+ '{% collapsecard "$1" %}$2{% endcollapsecard %}' ,
9393 )
9494 . replaceAll (
9595 / : : : s p o i l e r \n ( [ \S \s ] * ?) : : : / g,
96- '{% collapsecard "詳細" %}$1{% endcollapsecard %}'
96+ '{% collapsecard "詳細" %}$1{% endcollapsecard %}' ,
9797 )
9898 . replaceAll ( ":::info" , "{% blockquote %}" )
9999 . replaceAll ( ":::warning" , "{% blockquote %}" )
100100 . replaceAll ( ":::" , "{% endblockquote %}" )
101101 . replaceAll ( / \[ ^ \w + \] / g, " $0" )
102102 . replaceAll ( ":heavy_check_mark:" , '<div class="check"></div>' ) ,
103- urlToFileName
103+ urlToFileName ,
104104) }
105105` ;
106106 writeFileSync ( `source/_posts/${ fileName } .md` , markdownFileContent ) ;
0 commit comments