【已解决】如何在Obsidian中实现每日一句的功能?

用dataviewjs

let fileContent = await app.vault.readRaw(dv.page("一言").file.path)
let sentenceList = fileContent.split("\n")
sentenceList = sentenceList.filter(x => x.startsWith("·"))
let oneSentence = sentenceList[sentenceList.length * Math.random() | 0]
oneSentence = '每日一句:' + oneSentence.substring(2)
dv.paragraph(`<div style="padding-top: 1.5em; font-family: kaiti;">${oneSentence}</div>`) 

在保存句子时,开头加个·

2 个赞