Color mode

Daily Notes

Surfaces short snippets extracted from Daily Notes as a site widget.

日本語

Overview

A Daily Note is often one long, private journal file. This plugin reads the raw manifest, picks notes under a configured directory, and extracts exactly one short snippet per note using the first successful strategy:

  1. a frontmatter key (daily-summary by default),
  2. a section under a heading (今日のひとこと by default),
  3. a fenced code block (daily-snippet by default).

When every strategy fails the note is skipped. The note body is never emitted wholesale, so a long private note only contributes the snippet that opted in.

sourceUrl and sourceTitle are attached only when isPublished accepts the note. An unpublished note's permalink and title stay null, so private notes never leak their location.

Usage

ts
import { defineConfig } from "@riebeckite/core";
import { dailyNotesPlugin } from "@riebeckite/plugin-daily-notes";
 
export default defineConfig({
  // ...
  plugins: [dailyNotesPlugin()],
});

Render the widget

tsx
import DailyNotes, { getDailyNotes } from "@riebeckite/plugin-daily-notes";
 
const notes = getDailyNotes({ manifest, config });
 
return <DailyNotes notes={notes} />;

getDailyNotes reads manifest.entries (the raw view), sorts newest first, and applies the default limit of 5. Pass options to override the location or the extraction strategy:

ts
getDailyNotes({
  manifest,
  config,
  options: {
    source: {
      directory: "Daily",
      pathPattern: "Daily/{YYYY}-{MM}-{DD}",
      dateFormat: "YYYY/MM/DD",
    },
    extract: { frontmatter: "daily-summary", section: "今日のひとこと" },
    widget: { limit: 3 },
    dateFormat: "iso",
    locale: "en",
  },
});

Set a strategy to false to disable it. pathPattern supports {YYYY}, {MM}, {DD}, and * so a note filename can be matched precisely.

source.dateFormat is the Obsidian/Moment date format used by the note filenames (default YYYY-MM-DD). Set it to match Obsidian's Daily Notes date format (for example YYYY/MM/DD or YYYY.MM.DD); the slug date is read with exactly that format, and an unsupported format resolves no date rather than guessing another one.

dateFormat controls the widget date: "iso" (the default, YYYY-MM-DD), "long", or "short". "long" and "short" are rendered with locale (default "en"). The machine-readable YYYY-MM-DD value stays on the <time datetime> attribute regardless, and DailyNote.date keeps that ISO form while DailyNote.dateDisplay holds the formatted text.

Exports

  • dailyNotesPlugin(options?) — plugin factory (registers style.css)
  • getDailyNotes({ manifest, config, options? }) — sorted DailyNote[]
  • DailyNotes — widget component ({ notes, limit? })
  • resolveDisplayOptions(options?) — apply date-format defaults
  • formatDailyNoteDate(dateIso, display) — pure date formatter
  • Constants: DEFAULT_DAILY_NOTES_DATE_FORMAT, DEFAULT_DAILY_NOTES_LOCALE, DEFAULT_SLUG_DATE_FORMAT
  • Types: DailyNote, DailyNotesOptions, DailyNotesDateFormat, ResolvedDailyNotesExtract, ResolvedDailyNotesDisplay

See also

History

1 changesCollapseExpand
1 + <!-- Generated from packages/plugins/daily-notes/README.md. Do not edit this page directly; edit the package README and run `pnpm docs:sync`. -->
2 +
3 + # Daily Notes
4 +
5 + Surfaces short snippets extracted from Daily Notes as a site widget.
6 +
7 + [日本語](./daily-notes.md)
8 +
9 + ## Overview
10 +
11 + A Daily Note is often one long, private journal file. This plugin reads the raw
12 + manifest, picks notes under a configured directory, and extracts exactly one
13 + short snippet per note using the first successful strategy:
14 +
15 + 1. a frontmatter key (`daily-summary` by default),
16 + 2. a section under a heading (`今日のひとこと` by default),
17 + 3. a fenced code block (`daily-snippet` by default).
18 +
19 + When every strategy fails the note is skipped. The note body is never emitted
20 + wholesale, so a long private note only contributes the snippet that opted in.
21 +
22 + `sourceUrl` and `sourceTitle` are attached only when `isPublished` accepts the
23 + note. An unpublished note's permalink and title stay `null`, so private notes
24 + never leak their location.
25 +
26 + ## Usage
27 +
28 + ```ts
29 + import { defineConfig } from "@riebeckite/core";
30 + import { dailyNotesPlugin } from "@riebeckite/plugin-daily-notes";
31 +
32 + export default defineConfig({
33 + // ...
34 + plugins: [dailyNotesPlugin()],
35 + });
36 + ```
37 +
38 + ### Render the widget
39 +
40 + ```tsx
41 + import DailyNotes, { getDailyNotes } from "@riebeckite/plugin-daily-notes";
42 +
43 + const notes = getDailyNotes({ manifest, config });
44 +
45 + return <DailyNotes notes={notes} />;
46 + ```
47 +
48 + `getDailyNotes` reads `manifest.entries` (the raw view), sorts newest first,
49 + and applies the default limit of 5. Pass `options` to override the location or
50 + the extraction strategy:
51 +
52 + ```ts
53 + getDailyNotes({
54 + manifest,
55 + config,
56 + options: {
57 + source: {
58 + directory: "Daily",
59 + pathPattern: "Daily/{YYYY}-{MM}-{DD}",
60 + dateFormat: "YYYY/MM/DD",
61 + },
62 + extract: { frontmatter: "daily-summary", section: "今日のひとこと" },
63 + widget: { limit: 3 },
64 + dateFormat: "iso",
65 + locale: "en",
66 + },
67 + });
68 + ```
69 +
70 + Set a strategy to `false` to disable it. `pathPattern` supports `{YYYY}`,
71 + `{MM}`, `{DD}`, and `*` so a note filename can be matched precisely.
72 +
73 + `source.dateFormat` is the Obsidian/Moment date format used by the note
74 + filenames (default `YYYY-MM-DD`). Set it to match Obsidian's Daily Notes date
75 + format (for example `YYYY/MM/DD` or `YYYY.MM.DD`); the slug date is read with
76 + exactly that format, and an unsupported format resolves no date rather than
77 + guessing another one.
78 +
79 + `dateFormat` controls the widget date: `"iso"` (the default, `YYYY-MM-DD`),
80 + `"long"`, or `"short"`. `"long"` and `"short"` are rendered with `locale`
81 + (default `"en"`). The machine-readable `YYYY-MM-DD` value stays on the
82 + `<time datetime>` attribute regardless, and `DailyNote.date` keeps that ISO
83 + form while `DailyNote.dateDisplay` holds the formatted text.
84 +
85 + ## Exports
86 +
87 + - `dailyNotesPlugin(options?)` — plugin factory (registers `style.css`)
88 + - `getDailyNotes({ manifest, config, options? })` — sorted `DailyNote[]`
89 + - `DailyNotes` — widget component (`{ notes, limit? }`)
90 + - `resolveDisplayOptions(options?)` — apply date-format defaults
91 + - `formatDailyNoteDate(dateIso, display)` — pure date formatter
92 + - Constants: `DEFAULT_DAILY_NOTES_DATE_FORMAT`, `DEFAULT_DAILY_NOTES_LOCALE`,
93 + `DEFAULT_SLUG_DATE_FORMAT`
94 + - Types: `DailyNote`, `DailyNotesOptions`, `DailyNotesDateFormat`,
95 + `ResolvedDailyNotesExtract`, `ResolvedDailyNotesDisplay`
96 +
97 + ## See also
98 +
99 + - [Plugin guide](../reference/plugin-api.en.md)
100 +