Skip to content

Commit

Permalink
compiler: fix readme bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ys-zhifu committed Nov 14, 2024
1 parent 07488c7 commit b12e9b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion addTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const run = (sourceDir) => {
]);

// 如果没有permalink 则需要回写到md中
matterData.creatAt = createAt;
matterData.createAt = createAt;
matterData.updateAt = updateAt;

// 写入指定文件内即可
Expand Down
6 changes: 3 additions & 3 deletions vdoing/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</h1>
<div class="docs-time">
<span class="time"
>{{ locales[lang].createdAt }}:{{ creatAt }}</span
>{{ locales[lang].createdAt }}:{{ createAt }}</span
>
<span class="time"
>{{ locales[lang].updateAt }}:{{ updateAt }}</span
Expand Down Expand Up @@ -80,8 +80,8 @@ export default {
this.updateBarConfig = this.$themeConfig.updateBar;
},
computed: {
creatAt() {
return this.$frontmatter.creatAt?.split("T")[0] ?? "--";
createAt() {
return this.$frontmatter.createAt?.split("T")[0] ?? "--";
},
updateAt() {
return this.$frontmatter.updateAt?.split("T")[0] ?? "--";
Expand Down
10 changes: 6 additions & 4 deletions vdoing/node_utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ function handleFileAndGetSideBar (sourceDir, files, currentFileName) {
sidebar.push([getPermalink1(filePath), title, permalink])

if (!matterData.permalink && permalink) {
if (matterData.creatAt) {
matterData.creatAt = getReallyContent(matterData.creatAt);
if (matterData.createAt) {
matterData.createAt = getReallyContent(matterData.createAt);
}
if (matterData.updateAt) {
matterData.updateAt = getReallyContent(matterData.updateAt);
Expand Down Expand Up @@ -177,13 +177,15 @@ function handlerReadmeFile(filePath){
let directoryPath = null
if (hasReadme) {
const fileContent = fs.readFileSync(readmePath, "utf8");
const { data: matterData } = matter(fileContent, {});
const { data: matterData, content } = matter(fileContent, {});
directoryPath = matterData.permalink
if(!directoryPath){
directoryPath = getPermalink(filePath)
matterData.permalink = directoryPath
// 不存在permalink
// 需要改动下readme的内容
fs.writeFileSync(readmePath,`---\npermalink: ${directoryPath}\n---\n`+ fileContent);
const newFileContent = jsonToYaml.stringify(matterData).replace(/\n\s{2}/g, "\n").replace(/"/g, "") + '---' + os.EOL + content;
fs.writeFileSync(readmePath, newFileContent);
}
}
return directoryPath
Expand Down

0 comments on commit b12e9b2

Please sign in to comment.