Files
Notes/HomePage.md
2025-10-17 10:17:14 +02:00

8.3 KiB
Raw Blame History

cssclasses
cssclasses
wide-dashboard
no-properties
note-bg-blur
styled-checkbox
styled-hr
small-text

Dailys

Week

// Force English locale for weekdays
moment.locale("en");

const today = moment();

// === CONFIGURE WEEK RANGE HERE ===
// For current week:
const weekStart = today.clone().startOf("isoWeek");
const weekEnd   = today.clone().endOf("isoWeek");

// For next week, uncomment these:
// const weekStart = today.clone().add(1, "week").startOf("isoWeek");
// const weekEnd   = today.clone().add(1, "week").endOf("isoWeek");

// For weekend only (Sat & Sun):
// const weekStart = today.clone().startOf("isoWeek").add(5, "days"); // Saturday
// const weekEnd   = today.clone().startOf("isoWeek").add(6, "days"); // Sunday

// All notes tagged #Calendar within the week
const pages = dv.pages("#Calendar")
  .where(p => {
    const d = moment(p.file.name, "DD.MM.YYYY", true);
    return d.isValid() && d.isBetween(weekStart, weekEnd, "day", "[]");
  });

// Generate days array (MonSun or custom)
const totalDays = weekEnd.diff(weekStart, "days") + 1;
const weekDays = Array.from({ length: totalDays }, (_, i) => weekStart.clone().add(i, "days"));

// Separate days with and without notes
const daysWithNotes = [];
const daysWithoutNotes = [];

for (const day of weekDays) {
  const page = pages.find(p => p.file.name === day.format("DD.MM.YYYY"));
  if (page) {
    daysWithNotes.push({ date: day, page });
  } else {
    daysWithoutNotes.push(day);
  }
}

// Build Columns plugin Markdown
let md = "````col\nheight=shortest\ntextAlign=start\n===\n";

// Columns for days with notes
for (const { date, page } of daysWithNotes) {
  const isToday = date.isSame(today, "day");
  const label = `${isToday ? "📌 " : ""}${date.format("ddd")}<br>${date.format("DD.MM.YYYY")}`;

  md += "```col-md\n";
  md += `### ${label}\n`;

  // Show reason from frontmatter under the title
  if (page.reason) {
    md += `**Reason:** ${page.reason}\n\n`;
  }

  // Get tasks from the note
  const tasks = page.file.tasks;

  // Filter tasks under # Tasks heading if possible
  const tasksInSection = tasks.filter(t => {
    if (t.heading) return t.heading.toLowerCase().includes("tasks");
    return true; // fallback: include all tasks if heading not available
  });

  if (tasksInSection.length > 0) {
    for (const t of tasksInSection) {
      md += `- [${t.completed ? "x" : " "}] ${t.text}\n`;
    }
  } else {
    md += "_No tasks found_\n";
  }

  md += "```\n\n";
}

// Single column for days without notes
if (daysWithoutNotes.length > 0) {
  md += "```col-md\n";
  md += "### Days without notes\n";
  for (const day of daysWithoutNotes) {
    md += `- ${day.format("ddd")} — ${day.format("DD.MM.YYYY")}\n`;
  }
  md += "```\n\n";
}

md += "````\n";

// Render the dashboard
dv.paragraph(md);

Weekend

// Force English locale for weekdays
moment.locale("en");

const today = moment();

// === CONFIGURE WEEK RANGE HERE ===
// For current week:
//const weekStart = today.clone().startOf("isoWeek");
//const weekEnd   = today.clone().endOf("isoWeek");

// For next week, uncomment these:
// const weekStart = today.clone().add(1, "week").startOf("isoWeek");
// const weekEnd   = today.clone().add(1, "week").endOf("isoWeek");

// For weekend only (Sat & Sun):
const weekStart = today.clone().startOf("isoWeek").add(5, "days"); // Saturday
const weekEnd   = today.clone().startOf("isoWeek").add(6, "days"); // Sunday

// All notes tagged #Calendar within the week
const pages = dv.pages("#Calendar")
  .where(p => {
    const d = moment(p.file.name, "DD.MM.YYYY", true);
    return d.isValid() && d.isBetween(weekStart, weekEnd, "day", "[]");
  });

// Generate days array (MonSun or custom)
const totalDays = weekEnd.diff(weekStart, "days") + 1;
const weekDays = Array.from({ length: totalDays }, (_, i) => weekStart.clone().add(i, "days"));

// Separate days with and without notes
const daysWithNotes = [];
const daysWithoutNotes = [];

for (const day of weekDays) {
  const page = pages.find(p => p.file.name === day.format("DD.MM.YYYY"));
  if (page) {
    daysWithNotes.push({ date: day, page });
  } else {
    daysWithoutNotes.push(day);
  }
}

// Build Columns plugin Markdown
let md = "````col\nheight=shortest\ntextAlign=start\n===\n";

// Columns for days with notes
for (const { date, page } of daysWithNotes) {
  const isToday = date.isSame(today, "day");
  const label = `${isToday ? "📌 " : ""}${date.format("ddd")}<br>${date.format("DD.MM.YYYY")}`;

  md += "```col-md\n";
  md += `### ${label}\n`;

  // Show reason from frontmatter under the title
  if (page.reason) {
    md += `**Reason:** ${page.reason}\n\n`;
  }

  // Get tasks from the note
  const tasks = page.file.tasks;

  // Filter tasks under # Tasks heading if possible
  const tasksInSection = tasks.filter(t => {
    if (t.heading) return t.heading.toLowerCase().includes("tasks");
    return true; // fallback: include all tasks if heading not available
  });

  if (tasksInSection.length > 0) {
    for (const t of tasksInSection) {
      md += `- [${t.completed ? "x" : " "}] ${t.text}\n`;
    }
  } else {
    md += "_No tasks found_\n";
  }

  md += "```\n\n";
}

// Single column for days without notes
if (daysWithoutNotes.length > 0) {
  md += "```col-md\n";
  md += "### Days without notes\n";
  for (const day of daysWithoutNotes) {
    md += `- ${day.format("ddd")} — ${day.format("DD.MM.YYYY")}\n`;
  }
  md += "```\n\n";
}

md += "````\n";

// Render the dashboard
dv.paragraph(md);


Next Week

// Force English locale for weekdays
moment.locale("en");

const today = moment();

// === CONFIGURE WEEK RANGE HERE ===
// For current week:
//const weekStart = today.clone().startOf("isoWeek");
//const weekEnd   = today.clone().endOf("isoWeek");

// For next week, uncomment these:
const weekStart = today.clone().add(1, "week").startOf("isoWeek");
const weekEnd   = today.clone().add(1, "week").endOf("isoWeek");

// For weekend only (Sat & Sun):
// const weekStart = today.clone().startOf("isoWeek").add(5, "days"); // Saturday
// const weekEnd   = today.clone().startOf("isoWeek").add(6, "days"); // Sunday

// All notes tagged #Calendar within the week
const pages = dv.pages("#Calendar")
  .where(p => {
    const d = moment(p.file.name, "DD.MM.YYYY", true);
    return d.isValid() && d.isBetween(weekStart, weekEnd, "day", "[]");
  });

// Generate days array (MonSun or custom)
const totalDays = weekEnd.diff(weekStart, "days") + 1;
const weekDays = Array.from({ length: totalDays }, (_, i) => weekStart.clone().add(i, "days"));

// Separate days with and without notes
const daysWithNotes = [];
const daysWithoutNotes = [];

for (const day of weekDays) {
  const page = pages.find(p => p.file.name === day.format("DD.MM.YYYY"));
  if (page) {
    daysWithNotes.push({ date: day, page });
  } else {
    daysWithoutNotes.push(day);
  }
}

// Build Columns plugin Markdown
let md = "````col\nheight=shortest\ntextAlign=start\n===\n";

// Columns for days with notes
for (const { date, page } of daysWithNotes) {
  const isToday = date.isSame(today, "day");
  const label = `${isToday ? "📌 " : ""}${date.format("ddd")}<br>${date.format("DD.MM.YYYY")}`;

  md += "```col-md\n";
  md += `### ${label}\n`;

  // Show reason from frontmatter under the title
  if (page.reason) {
    md += `**Reason:** ${page.reason}\n\n`;
  }

  // Get tasks from the note
  const tasks = page.file.tasks;

  // Filter tasks under # Tasks heading if possible
  const tasksInSection = tasks.filter(t => {
    if (t.heading) return t.heading.toLowerCase().includes("tasks");
    return true; // fallback: include all tasks if heading not available
  });

  if (tasksInSection.length > 0) {
    for (const t of tasksInSection) {
      md += `- [${t.completed ? "x" : " "}] ${t.text}\n`;
    }
  } else {
    md += "_No tasks found_\n";
  }

  md += "```\n\n";
}

// Single column for days without notes
if (daysWithoutNotes.length > 0) {
  md += "```col-md\n";
  md += "### Days without notes\n";
  for (const day of daysWithoutNotes) {
    md += `- ${day.format("ddd")} — ${day.format("DD.MM.YYYY")}\n`;
  }
  md += "```\n\n";
}

md += "````\n";

// Render the dashboard
dv.paragraph(md);