<%* const MAX_DAYS = 30; let tomorrowGoals = ""; let dedupedUnfinished = ""; let daysAgo = 0; let foundDate = null;
for (let i = 1; i ⇐ MAX_DAYS; i++) { const targetDate = moment().subtract(i, ‘days’).format(‘YYYY-MM-DD’); const targetFile = tp.file.find_tfile(targetDate);
if (targetFile) {
const content = await tp.file.include("[[" + targetDate + "]]");
const goalMatch = content.match(/## 明日目标\n([\s\S]*?)(?=\n## |\n---|\n#[^#]|$)/);
tomorrowGoals = goalMatch ? goalMatch[1].trim() : "";
const unfinished = content
.split('\n')
.filter(line => line.match(/^- \[ \]/))
.join('\n');
if (tomorrowGoals || unfinished) {
const tomorrowLines = new Set(tomorrowGoals.split('\n').map(l => l.trim()));
dedupedUnfinished = unfinished
.split('\n')
.filter(line => !tomorrowLines.has(line.trim()))
.join('\n');
daysAgo = i;
foundDate = targetDate;
break;
}
}
}
const dateHint = daysAgo > 1 ? <!-- 来自 ${foundDate},${daysAgo} 天前 --> : "";
const todayGoals = tomorrowGoals || ”- [ ] ”;
const carriedBlock = dedupedUnfinished
? dedupedUnfinished
: “(无延续任务)”;
-%>
<% tp.date.now(“YYYY-MM-DD”) %>
今日目标
<% todayGoals %>
今日记录
延续目标
<% daysAgo > 1 ? > [!note] 来自 ${foundDate}(${daysAgo} 天前)\n\n + carriedBlock : carriedBlock %>
今日复盘
- 推进了什么:
- 浪费在哪:
- 明天关键:
明日目标
- [ ]