Skip to content

Commit c01e2ae

Browse files
committed
compiler: fix readme bug
1 parent 7ea3aee commit c01e2ae

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

addTime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const run = (sourceDir) => {
9292
]);
9393

9494
// 如果没有permalink 则需要回写到md中
95-
matterData.creatAt = createAt;
95+
matterData.createAt = createAt;
9696
matterData.updateAt = updateAt;
9797

9898
// 写入指定文件内即可

vdoing/components/Page.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</h1>
2626
<div class="docs-time">
2727
<span class="time"
28-
>{{ locales[lang].createdAt }}:{{ creatAt }}</span
28+
>{{ locales[lang].createdAt }}:{{ createAt }}</span
2929
>
3030
<span class="time"
3131
>{{ locales[lang].updateAt }}:{{ updateAt }}</span
@@ -80,8 +80,8 @@ export default {
8080
this.updateBarConfig = this.$themeConfig.updateBar;
8181
},
8282
computed: {
83-
creatAt() {
84-
return this.$frontmatter.creatAt?.split("T")[0] ?? "--";
83+
createAt() {
84+
return this.$frontmatter.createAt?.split("T")[0] ?? "--";
8585
},
8686
updateAt() {
8787
return this.$frontmatter.updateAt?.split("T")[0] ?? "--";

vdoing/node_utils/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)