blob: d5ac16b624c9a8224b8fb383195a8422a0bb35e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import type { Component } from 'svelte';
export type PostMetadata<Parsed extends boolean = false> = {
title: string;
blurb: string;
author: string | null;
slug: string;
id: string | number;
created: Parsed extends true ? Date : string;
updated: Parsed extends true ? Date : string;
published: boolean | 'unlisted';
/** If false (defaults to true), author panel at the bottom of the page is hidden. This is the case for the clickbait article. */
authorpanel?: boolean;
};
export type Post<MetadataParsed extends boolean = false> = {
metadata: PostMetadata<MetadataParsed>;
default: Component;
};
export const parsePostMetadata = (
m: PostMetadata<boolean>,
): PostMetadata<true> => ({
...m,
created: new Date(m.created),
updated: new Date(m.updated),
});
export const parsePost = (p: Post<boolean>): Post<true> => ({
...p,
metadata: parsePostMetadata(p.metadata),
});
|