Skip to content

Instantly share code, notes, and snippets.

@appendjeff
Created January 1, 2026 18:28
Show Gist options
  • Select an option

  • Save appendjeff/0ddfc2354ca5c152336dc58af6bbb601 to your computer and use it in GitHub Desktop.

Select an option

Save appendjeff/0ddfc2354ca5c152336dc58af6bbb601 to your computer and use it in GitHub Desktop.
Render the "Today's story" section of daily notes between two dates
/**
* Renders stories from daily notes within a specific date range.
* @param {Object} dv - The Dataview instance.
* @param {string} start - Start date "YYYY-MM-DD".
* @param {string} end - End date "YYYY-MM-DD".
*
* Built with gemini: https://gemini.google.com/share/45f540e8daec
*/
async function renderTripStories(dv, start, end) {
const startDate = moment(start);
const endDate = moment(end);
const pages = dv.pages('"Daily"')
.where(p => {
if (!p.file.day) return false;
const d = moment(p.file.day.toString());
// Filter: date is between start and end (inclusive)
return d.isSameOrAfter(startDate) && d.isSameOrBefore(endDate);
})
.sort(p => p.file.day, 'asc'); // Usually trips look better in chronological order
for (const p of pages) {
const d = moment(p.file.day.toString());
const journalDate = d.format("dddd MMMM Do 'YY");
const dailyNoteDate = d.format("YYYY-MM-DD");
const content = await dv.io.load(p.file.path);
if (!content) continue;
const storyMatch = content.match(/## Today's story\s*\n([\s\S]*?)(?=\n##|\n#|$)/);
const storyContent = (storyMatch ? storyMatch[1].trim() : null);
if (storyContent) {
dv.paragraph(`### [[${dailyNoteDate}|${journalDate}]]`);
dv.paragraph(storyContent);
dv.paragraph("---");
}
}
}
// Export the function so it can be used elsewhere
module.exports = renderTripStories;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment