make it works again

This commit is contained in:
Seungjun Lee
2026-07-29 16:55:49 +09:00
parent 06659df73a
commit 20285c0f81
3 changed files with 9 additions and 4 deletions
+5 -1
View File
@@ -19,7 +19,7 @@ export default class PAUL extends Plugin {
if (activeFile && activeFile.extension === 'md') {
this.app.vault.read(activeFile).then(content => {
const pattern = /Modified: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/;
let digit = (inp)=>{ return String(inp).padStart(2, '0') }
const digit = (inp: number)=>{ return String(inp).padStart(2, '0') }
const t = new Date()
const modified = `Modified: ${t.getFullYear()}-${digit(t.getMonth()+1)}-${digit(t.getDate())}T${digit(t.getHours())}:${digit(t.getMinutes())}:${digit(t.getSeconds())}Z`;
@@ -32,6 +32,10 @@ export default class PAUL extends Plugin {
const analysis = content.match(/^---\n((?!-{3})(?:(?:.+:.*)|(?:\s{2}-\s.+))\n)+---/);
// const analysis = content.match(/---\n(.*:.*\n)*---/s);
// console.log(analysis);
// frontmatter가 없으면 삽입할 위치를 찾을 수 없으므로 중단
if (!analysis || analysis.index === undefined) {
return;
}
const pnt = analysis.index + analysis[0].length - 3;
this.app.vault.modify(activeFile, content.slice(0, pnt) + modified + '\n' + content.slice(pnt));
}