at main 1.4 kB view raw
1type Prettify<T> = { 2 [K in keyof T]: T[K]; 3} & {}; 4 5type SharingProvider = "bluesky" | "clipboard" | "native"; 6 7export type BlogConfig = { 8 site: string; 9 tableOfContents: boolean; 10 sharingProviders: SharingProvider[]; 11 title: string; 12 author: string; 13 authorDid: `did:plc:${string}`; 14 meta: { 15 name: string; 16 content: string; 17 }[]; 18 links: { 19 bluesky?: `https://bsky.app/profile/${string}`; 20 github?: `https://github.com/${string}`; 21 mastodon?: `https://${string}/@${string}`; 22 }; 23}; 24 25export function defineBlogConfig(config: Prettify<Partial<BlogConfig>>) { 26 return { 27 site: config.site ?? "https://example.com", 28 tableOfContents: config.tableOfContents ?? true, 29 sharingProviders: config.sharingProviders 30 ? config.sharingProviders.reduce( 31 (acc, provider) => { 32 acc[provider] = true; 33 return acc; 34 }, 35 {} as Record<SharingProvider, boolean> 36 ) 37 : { bluesky: true, clipboard: true, native: true }, 38 title: config.title ?? "My Blog", 39 author: config.author ?? "finxol", 40 authorDid: config.authorDid, 41 meta: config.meta ?? [ 42 { name: "description", content: "My blog description" } 43 ], 44 links: config.links ?? {} 45 }; 46}