mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-04 02:52:55 +08:00
- Introduced a new documentation site for Cursor BYOK using Next.js and Fumadocs. - Added a product demo page with a corresponding Vite configuration. - Implemented a demo API to simulate LLM calls and responses. - Enhanced the Makefile to include new build and development commands for the documentation. - Updated package.json scripts for building and running the documentation site. - Created various components and layouts for the documentation structure, including blog and user documentation sections. - Added styling for the new components and layouts to ensure a cohesive design. - Included a README and other necessary files for local development and deployment.
36 lines
1003 B
TypeScript
36 lines
1003 B
TypeScript
import { loader } from 'fumadocs-core/source';
|
|
import { pageSchema } from 'fumadocs-core/source/schema';
|
|
import { defineCollections } from 'fumadocs-mdx/macro';
|
|
|
|
const blog = defineCollections({
|
|
type: 'doc',
|
|
dir: 'content/blog',
|
|
schema: pageSchema,
|
|
});
|
|
|
|
export const blogSource = loader({
|
|
baseUrl: '/blog',
|
|
source: blog.toFumadocsSource(),
|
|
});
|
|
|
|
export function getBlogDate(path: string): Date {
|
|
const fileName = path.split('/').at(-1) ?? '';
|
|
const match = /^(\d{4}-\d{2}-\d{2})/.exec(fileName);
|
|
return match ? new Date(`${match[1]}T00:00:00Z`) : new Date(0);
|
|
}
|
|
|
|
export function formatBlogDate(path: string): string {
|
|
return new Intl.DateTimeFormat('zh-CN', {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
timeZone: 'UTC',
|
|
}).format(getBlogDate(path));
|
|
}
|
|
|
|
export function sortBlogPages<T extends { path: string }>(pages: T[]): T[] {
|
|
return [...pages].sort((left, right) => {
|
|
return getBlogDate(right.path).getTime() - getBlogDate(left.path).getTime();
|
|
});
|
|
}
|