B2B-88: add starter kit structure and elements

This commit is contained in:
devmc-ee
2025-06-08 16:18:30 +03:00
parent 657a36a298
commit e7b25600cb
1280 changed files with 77893 additions and 5688 deletions

View File

@@ -0,0 +1,3 @@
# CMS - @kit/cms
CMS abstraction layer for the Makerkit framework.

View File

@@ -0,0 +1,3 @@
import eslintConfigBase from '@kit/eslint-config/base.js';
export default eslintConfigBase;

1
packages/cms/core/node_modules/@kit/cms-types generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../types

1
packages/cms/core/node_modules/@kit/eslint-config generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../../../tooling/eslint

1
packages/cms/core/node_modules/@kit/keystatic generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../keystatic

1
packages/cms/core/node_modules/@kit/prettier-config generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../../../tooling/prettier

1
packages/cms/core/node_modules/@kit/shared generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../../shared

1
packages/cms/core/node_modules/@kit/tsconfig generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../../../tooling/typescript

1
packages/cms/core/node_modules/@kit/wordpress generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../wordpress

1
packages/cms/core/node_modules/@types/node generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../../../../node_modules/.pnpm/@types+node@22.15.30/node_modules/@types/node

View File

@@ -0,0 +1,32 @@
{
"name": "@kit/cms",
"private": true,
"version": "0.1.0",
"scripts": {
"clean": "git clean -xdf .turbo node_modules",
"format": "prettier --check \"**/*.{ts,tsx}\"",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"prettier": "@kit/prettier-config",
"exports": {
".": "./src/index.ts"
},
"devDependencies": {
"@kit/cms-types": "workspace:*",
"@kit/eslint-config": "workspace:*",
"@kit/keystatic": "workspace:*",
"@kit/prettier-config": "workspace:*",
"@kit/shared": "workspace:*",
"@kit/tsconfig": "workspace:*",
"@kit/wordpress": "workspace:*",
"@types/node": "^22.15.18"
},
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
}
}

View File

@@ -0,0 +1,48 @@
import type { CmsType } from '@kit/cms-types';
const CMS_CLIENT = process.env.CMS_CLIENT as CmsType;
interface ContentRendererProps {
content: unknown;
type?: CmsType;
}
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(
'@kit/keystatic/renderer'
);
return KeystaticContentRenderer;
}
case 'wordpress': {
const { WordpressContentRenderer } = await import(
'@kit/wordpress/renderer'
);
return WordpressContentRenderer;
}
default: {
console.error(`Unknown CMS client: ${type as string}`);
return null;
}
}
}

View File

@@ -0,0 +1,33 @@
import { CmsClient, CmsType } from '@kit/cms-types';
import { createRegistry } from '@kit/shared/registry';
/**
* The type of CMS client to use.
*/
const CMS_CLIENT = process.env.CMS_CLIENT as CmsType;
// Create a registry for CMS client implementations
const cmsRegistry = createRegistry<CmsClient, CmsType>();
// Register the WordPress CMS client implementation
cmsRegistry.register('wordpress', async () => {
const { createWordpressClient } = await import('@kit/wordpress');
return createWordpressClient();
});
// Register the Keystatic CMS client implementation
cmsRegistry.register('keystatic', async () => {
const { createKeystaticClient } = await import('@kit/keystatic');
return createKeystaticClient();
});
/**
* Creates a CMS client based on the specified type.
*
* @param {CmsType} type - The type of CMS client to create. Defaults to the value of the CMS_CLIENT environment variable.
* @returns {Promise<CmsClient>} A Promise that resolves to the created CMS client.
* @throws {Error} If the specified CMS type is unknown.
*/
export async function createCmsClient(type: CmsType = CMS_CLIENT) {
return cmsRegistry.get(type);
}

View File

@@ -0,0 +1,6 @@
import { Cms } from '@kit/cms-types';
export * from './create-cms-client';
export * from './content-renderer';
export type { Cms };

View File

@@ -0,0 +1,8 @@
{
"extends": "@kit/tsconfig/base.json",
"compilerOptions": {
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": ["src"],
"exclude": ["node_modules"]
}