Obsidian Publish 날짜 표시

Obsidian 마크다운에서 메타 정보 관리를 위해서 Frontmatter YAML 방식을 지원하고 있다.

노트에 작성 날짜 정보가 필요한 경우가 있어 이를 대응하기 위한 스크립트를 작성하였다.

app.registerMarkdownPostProcessor(async (e, t) => {
    if (t.frontmatter && t.frontmatter.date && e.find(".frontmatter")) {
        const el = document.createElement("div")
        el.className = "cr-post-date"
        el.textContent = t.frontmatter.date
        e.appendChild(el)
    }
})
.cr-post-date {
    color: var(--text-faint);
    font-family: var(--font-monospace);
    position: relative;
    top: -26px;
}

Markdown

---
date: 2019-09-29
---

여기서부터 본문 내용.