mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-31 19:15:17 +02:00
refactor ensure-daily-note
This commit is contained in:
parent
a86f555cbb
commit
fbbaeea1df
1 changed files with 5 additions and 5 deletions
|
|
@ -3,13 +3,14 @@ import fs from 'fs';
|
||||||
import { stringify as stringifyYaml } from 'yaml';
|
import { stringify as stringifyYaml } from 'yaml';
|
||||||
import { TrackBlockSchema } from '@x/shared/dist/track-block.js';
|
import { TrackBlockSchema } from '@x/shared/dist/track-block.js';
|
||||||
import { WorkDir } from '../config/config.js';
|
import { WorkDir } from '../config/config.js';
|
||||||
|
import z from 'zod';
|
||||||
|
|
||||||
const KNOWLEDGE_DIR = path.join(WorkDir, 'knowledge');
|
const KNOWLEDGE_DIR = path.join(WorkDir, 'knowledge');
|
||||||
const DAILY_NOTE_PATH = path.join(KNOWLEDGE_DIR, 'Today.md');
|
const DAILY_NOTE_PATH = path.join(KNOWLEDGE_DIR, 'Today.md');
|
||||||
|
|
||||||
interface Section {
|
interface Section {
|
||||||
heading: string;
|
heading: string;
|
||||||
track: unknown;
|
track: z.infer<typeof TrackBlockSchema>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SECTIONS: Section[] = [
|
const SECTIONS: Section[] = [
|
||||||
|
|
@ -143,8 +144,7 @@ Do NOT invent busywork.`,
|
||||||
function buildDailyNoteContent(): string {
|
function buildDailyNoteContent(): string {
|
||||||
const parts: string[] = ['# Today', ''];
|
const parts: string[] = ['# Today', ''];
|
||||||
for (const { heading, track } of SECTIONS) {
|
for (const { heading, track } of SECTIONS) {
|
||||||
const parsed = TrackBlockSchema.parse(track);
|
const yaml = stringifyYaml(track, { lineWidth: 0, blockQuote: 'literal' }).trimEnd();
|
||||||
const yaml = stringifyYaml(parsed, { lineWidth: 0, blockQuote: 'literal' }).trimEnd();
|
|
||||||
parts.push(
|
parts.push(
|
||||||
heading,
|
heading,
|
||||||
'',
|
'',
|
||||||
|
|
@ -152,8 +152,8 @@ function buildDailyNoteContent(): string {
|
||||||
yaml,
|
yaml,
|
||||||
'```',
|
'```',
|
||||||
'',
|
'',
|
||||||
`<!--track-target:${parsed.trackId}-->`,
|
`<!--track-target:${track.trackId}-->`,
|
||||||
`<!--/track-target:${parsed.trackId}-->`,
|
`<!--/track-target:${track.trackId}-->`,
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue