Add date formatter, language and text direction settings

This commit is contained in:
prototypa
2023-01-08 12:28:59 -05:00
parent a210c72431
commit 8ce8421334
12 changed files with 121 additions and 65 deletions

View File

@ -4,14 +4,14 @@ import type { Post } from '~/types';
import { cleanSlug } from './permalinks';
const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise<Post> => {
const { id, slug, data } = post;
const { id, slug = '', data } = post;
const { Content, injectedFrontmatter } = await post.render();
const { tags = [], category = 'default', author = 'Anonymous', publishDate, ...rest } = data;
const { tags = [], category = 'default', author = 'Anonymous', publishDate = new Date(), ...rest } = data;
return {
id: id,
slug: slug,
slug: cleanSlug(slug.split('/').pop() ?? ''),
publishDate: new Date(publishDate),
category: cleanSlug(category),