master @ 15 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ // Pure content helpers. astro:content stays in the pages so this │
│ // module is unit-testable. │
│ │
│ export const published = ({ data }: { data: { draft?: boolean } }) => !data.draft; │
│ │
│ /** First path segment of a collection id: the subject / topic / │
│ * project the directory taxonomy assigns. */ │
│ export const topSegment = (id: string): string => id.split("/")[0] ?? id; │
│ │
│ type HasPublished = { data: { published: string } }; │
│ │
│ /** Ascending by ISO publish date; ties break on id for stability. */ │
│ export const byPublished = (a: HasPublished & { id: string }, b: HasPublished & { │
│ id: string }): number => │
│ a.data.published.localeCompare(b.data.published) || a.id.localeCompare(b.id); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ // Pure content helpers. astro:content stays │
│ in the pages so this │
│ // module is unit-testable. │
│ │
│ export const published = ({ data }: { data: │
│ { draft?: boolean } }) => !data.draft; │
│ │
│ /** First path segment of a collection id: t │
│ he subject / topic / │
│ * project the directory taxonomy assigns. │
│ */ │
│ export const topSegment = (id: string): stri │
│ ng => id.split("/")[0] ?? id; │
│ │
│ type HasPublished = { data: { published: str │
│ ing } }; │
│ │
│ /** Ascending by ISO publish date; ties brea │
│ k on id for stability. */ │
│ export const byPublished = (a: HasPublished │
│ & { id: string }, b: HasPublished & { id: st │
│ ring }): number => │
│ a.data.published.localeCompare(b.data.publ │
│ ished) || a.id.localeCompare(b.id); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET