Refactored CMS packages to remove a circular dependency (#62)
This commit is contained in:
committed by
GitHub
parent
51a40b6d40
commit
d18f810c6e
@@ -1,4 +1,4 @@
|
||||
import type { CmsType } from './cms.type';
|
||||
import type { CmsType } from '@kit/cms-types';
|
||||
|
||||
const CMS_CLIENT = process.env.CMS_CLIENT as CmsType;
|
||||
|
||||
@@ -11,21 +11,32 @@ export async function ContentRenderer({
|
||||
content,
|
||||
type = CMS_CLIENT,
|
||||
}: ContentRendererProps) {
|
||||
const Renderer = await getContentRenderer(type);
|
||||
|
||||
return Renderer ? <Renderer content={content} /> : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content renderer for the specified CMS client.
|
||||
*
|
||||
* @param {CmsType} type - The type of CMS client.
|
||||
*/
|
||||
async function getContentRenderer(type: CmsType) {
|
||||
switch (type) {
|
||||
case 'keystatic': {
|
||||
const { KeystaticContentRenderer } = await import(
|
||||
'../../keystatic/src/content-renderer'
|
||||
'@kit/keystatic/renderer'
|
||||
);
|
||||
|
||||
return <KeystaticContentRenderer content={content} />;
|
||||
return KeystaticContentRenderer;
|
||||
}
|
||||
|
||||
case 'wordpress': {
|
||||
const { WordpressContentRenderer } = await import(
|
||||
'../../wordpress/src/content-renderer'
|
||||
'@kit/wordpress/renderer'
|
||||
);
|
||||
|
||||
return <WordpressContentRenderer content={content} />;
|
||||
return WordpressContentRenderer;
|
||||
}
|
||||
|
||||
default: {
|
||||
|
||||
Reference in New Issue
Block a user