2025년 05월

@VERO
Created Date · 2025년 05월 01일 11:05
Last Updated Date · 2025년 05월 01일 11:05

const title = dv.current().file.frontmatter.title;
const match = title.match(/(\d{4})년\s*(\d{2})월/);

if (!match) {
  throw new Error("title 형식이 'YYYY년 MM월'이 아닙니다.");
}

const yyyy = match[1];
const mm = match[2];

const from = moment(`${yyyy}-${mm}-01`, "YYYY-MM-DD");
const to = moment(from).endOf("month");

console.log("From:", from.format("YYYY-MM-DD"));
console.log("To:", to.format("YYYY-MM-DD"));

dv.table(["Date", "TIL"],
  dv.pages("")
    .where(p => {
      const name = p.file.name;
      if (!/^\d{4}-\d{2}-\d{2}$/.test(name)) return false;

      const date = moment(name, "YYYY-MM-DD");
      return date.isBetween(from, to, null, "[]");
    })
    .sort(p => p.file.name)
    .map(p => [moment(p.file.name, "YYYY-MM-DD").format("YYYY년 MM월 DD일"), p.file.link])
);