plugins icon indicating copy to clipboard operation
plugins copied to clipboard

🧩 logseq.Editor.getPage

Open utterances-bot opened this issue 2 years ago • 1 comments

https://plugins-doc.logseq.com/logseq/Editor/getPage

utterances-bot avatar Jun 15 '23 03:06 utterances-bot

Get journalDay as Date (For TypeScript)

const getJournalDayDate = (str: string): Date => new Date(
  Number(str.slice(0, 4)), //year
  Number(str.slice(4, 6)) - 1, //month 0-11
  Number(str.slice(6)) //day
);

const { journalDay } = await logseq.Editor.getCurrentPage() as PageEntity;
if (!journalDay) {
  console.error('journalDay is undefined');
  return;
}
const targetDate:Date = getJournalDayDate(String(journalDay)) as Date;

getCurrentPage() or getPage(uuid)

YU000jp avatar Jun 15 '23 03:06 YU000jp