Skip to content

Listing content of sub-headings by date? #1557

Answered by aravindsv
aravindsv asked this question in Q&A
Discussion options

You must be logged in to vote

Managed to figure out an answer to my own question! Pasting code here in case someone needs it in the future, or if there's improvements that can be made:

dv.header(1, "Project Work");
const file_title = dv.current().file.mday;
const luxon_date = dv.date(file_title);
const date = luxon_date.toFormat("yyyy-MM-dd");

const pages = dv.pages('"Projects"');
const filter_text = date;

const regex = new RegExp(`#+ ${date}\r?\n(.*?)(\n#+ |\n---|$)`, "s");
for (const page of pages) {
    const file_contents = await dv.io.load(page.file.path);
    const header_match = file_contents.match(regex);
    if (header_match) {
        dv.header(2, (dv.sectionLink(page.file.name, date, false, page.file.name…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@huyz
Comment options

Answer selected by aravindsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants