Initial commit
This commit is contained in:
7
lib/config.ts
Normal file
7
lib/config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const siteConfig = {
|
||||
name: 'Your Name',
|
||||
title: 'Your Personal Site',
|
||||
description: 'Personal homepage and blog.',
|
||||
url: 'http://localhost:3000'
|
||||
};
|
||||
|
||||
28
lib/posts.ts
Normal file
28
lib/posts.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { allPosts, allPages, Post, Page } from 'contentlayer/generated';
|
||||
|
||||
export function getAllPostsSorted(): Post[] {
|
||||
return [...allPosts].sort((a, b) => {
|
||||
const aDate = a.published_at ? new Date(a.published_at).getTime() : 0;
|
||||
const bDate = b.published_at ? new Date(b.published_at).getTime() : 0;
|
||||
return bDate - aDate;
|
||||
});
|
||||
}
|
||||
|
||||
export function getPostBySlug(slug: string): Post | undefined {
|
||||
return allPosts.find(
|
||||
(post) =>
|
||||
post.flattenedPath === slug ||
|
||||
post.slug === slug ||
|
||||
post._raw.flattenedPath === slug
|
||||
);
|
||||
}
|
||||
|
||||
export function getPageBySlug(slug: string): Page | undefined {
|
||||
return allPages.find(
|
||||
(page) =>
|
||||
page.flattenedPath === slug ||
|
||||
page.slug === slug ||
|
||||
page._raw.flattenedPath === slug
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user