@@ -106,8 +106,8 @@ function handleFileAndGetSideBar (sourceDir, files, currentFileName) {
106106 sidebar . push ( [ getPermalink1 ( filePath ) , title , permalink ] )
107107
108108 if ( ! matterData . permalink && permalink ) {
109- if ( matterData . creatAt ) {
110- matterData . creatAt = getReallyContent ( matterData . creatAt ) ;
109+ if ( matterData . createAt ) {
110+ matterData . createAt = getReallyContent ( matterData . createAt ) ;
111111 }
112112 if ( matterData . updateAt ) {
113113 matterData . updateAt = getReallyContent ( matterData . updateAt ) ;
@@ -177,13 +177,15 @@ function handlerReadmeFile(filePath){
177177 let directoryPath = null
178178 if ( hasReadme ) {
179179 const fileContent = fs . readFileSync ( readmePath , "utf8" ) ;
180- const { data : matterData } = matter ( fileContent , { } ) ;
180+ const { data : matterData , content } = matter ( fileContent , { } ) ;
181181 directoryPath = matterData . permalink
182182 if ( ! directoryPath ) {
183183 directoryPath = getPermalink ( filePath )
184+ matterData . permalink = directoryPath
184185 // 不存在permalink
185186 // 需要改动下readme的内容
186- fs . writeFileSync ( readmePath , `---\npermalink: ${ directoryPath } \n---\n` + fileContent ) ;
187+ const newFileContent = jsonToYaml . stringify ( matterData ) . replace ( / \n \s { 2 } / g, "\n" ) . replace ( / " / g, "" ) + '---' + os . EOL + content ;
188+ fs . writeFileSync ( readmePath , newFileContent ) ;
187189 }
188190 }
189191 return directoryPath
0 commit comments