make it works again
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user