Initial commit

This commit is contained in:
2025-11-17 15:28:20 +08:00
commit 0c64279e34
100 changed files with 23827 additions and 0 deletions

7
lib/config.ts Normal file
View 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
View 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
);
}