Replaced contentlayer with keystatic
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "workspace:*",
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*"
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@types/node": "^20.12.7"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -5,7 +5,7 @@ export namespace Cms {
|
||||
title: string;
|
||||
url: string;
|
||||
description: string | undefined;
|
||||
content: string;
|
||||
content: unknown;
|
||||
author: string;
|
||||
publishedAt: Date;
|
||||
image: string | undefined;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// we can add more types here if we have more CMSs
|
||||
// ex. export type CmsType = 'contentlayer' | 'other-cms';
|
||||
export type CmsType = 'contentlayer' | 'wordpress';
|
||||
export type CmsType = 'wordpress' | 'keystatic';
|
||||
|
||||
@@ -4,16 +4,16 @@ export async function ContentRenderer({
|
||||
content,
|
||||
type = process.env.CMS_CLIENT as CmsType,
|
||||
}: {
|
||||
content: string;
|
||||
content: unknown;
|
||||
type?: CmsType;
|
||||
}) {
|
||||
switch (type) {
|
||||
case 'contentlayer': {
|
||||
const { MDXContentRenderer } = await import(
|
||||
'../../contentlayer/src/content-renderer'
|
||||
case 'keystatic': {
|
||||
const { KeystaticDocumentRenderer } = await import(
|
||||
'../../keystatic/src/content-renderer'
|
||||
);
|
||||
|
||||
return MDXContentRenderer({ content });
|
||||
return KeystaticDocumentRenderer({ content });
|
||||
}
|
||||
|
||||
case 'wordpress': {
|
||||
|
||||
@@ -16,25 +16,25 @@ export async function createCmsClient(
|
||||
|
||||
async function cmsClientFactory(type: CmsType) {
|
||||
switch (type) {
|
||||
case 'contentlayer':
|
||||
return getContentLayerClient();
|
||||
|
||||
case 'wordpress':
|
||||
return getWordpressClient();
|
||||
|
||||
case 'keystatic':
|
||||
return getKeystaticClient();
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown CMS type`);
|
||||
}
|
||||
}
|
||||
|
||||
async function getContentLayerClient() {
|
||||
const { ContentlayerClient } = await import('../../contentlayer/src/client');
|
||||
|
||||
return new ContentlayerClient();
|
||||
}
|
||||
|
||||
async function getWordpressClient() {
|
||||
const { WordpressClient } = await import('../../wordpress/src/wp-client');
|
||||
|
||||
return new WordpressClient();
|
||||
}
|
||||
|
||||
async function getKeystaticClient() {
|
||||
const { KeystaticClient } = await import('../../keystatic/src/client');
|
||||
|
||||
return new KeystaticClient();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user