Something went wrong. Try again.
atproto git client
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031import { getCollection } from 'astro:content'
/** * The notes, newest first, with drafts left out of a build. * * One function because three things have to agree about what has been * posted: the index, a note's own page, and the feed. The draft rule is on * `import.meta.env.DEV` rather than a flag, so there is no way to ship one * by forgetting to turn something back on. */export async function publishedNotes() { const notes = await getCollection( 'posts', ({ data }) => import.meta.env.DEV || !data.draft, ) return notes.sort( (a, b) => b.data.publishDate.getTime() - a.data.publishDate.getTime(), )}
/** When a note last changed, which is what a feed's `updated` means. */export function changed(note: { data: { publishDate: Date; updatedDate?: Date } }): Date { return note.data.updatedDate ?? note.data.publishDate}
/** The one date format the site uses. UTC, so a build cannot move a date. */export const day = new Intl.DateTimeFormat('en', { dateStyle: 'long', timeZone: 'UTC',})