mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 10:55:57 +00:00
CLI: support init with JSON schema
This commit is contained in:
@@ -16,8 +16,7 @@
|
||||
"./build": {
|
||||
"import": "./dist/build/index.js",
|
||||
"types": "./dist/build/index.d.ts"
|
||||
},
|
||||
"./schema/*": "./dist/schema/*"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"bin": {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
## Fumadocs Registry
|
||||
|
||||
A Fumadocs registry is similar to Shadcn registry, but included more hints for accurate replication of original file structure.
|
||||
|
||||
Different from Shadcn CLI (currently), Fumadocs CLI has better support for using another base URL for registry.
|
||||
For example, `index.json` was only supported for Shadcn UI itself but not custom registries.
|
||||
|
||||
## Definition
|
||||
|
||||
index file: `{base_url}/_registry.json`, type: `OutputIndex[]`.
|
||||
component file: `{base_url}/{name}.json`, type: `OutputComponent`.
|
||||
|
||||
We have a smarter build system that can accurately detect references to deps, local files, and sub component.
|
||||
@@ -12,6 +12,14 @@ export function createConfigSchema(isSrc: boolean) {
|
||||
};
|
||||
|
||||
return z.object({
|
||||
$schema: z
|
||||
.string()
|
||||
.default(
|
||||
isSrc
|
||||
? 'node_modules/@fumadocs/cli/dist/schema/src.json'
|
||||
: 'node_modules/@fumadocs/cli/dist/schema/default.json',
|
||||
)
|
||||
.optional(),
|
||||
aliases: z
|
||||
.object({
|
||||
uiDir: z.string().default(defaultAliases.uiDir),
|
||||
|
||||
@@ -17,7 +17,7 @@ export function toImportSpecifier(
|
||||
const extname = path.extname(referenceFile);
|
||||
const removeExt = typescriptExtensions.includes(extname);
|
||||
|
||||
const importPath = path
|
||||
let importPath = path
|
||||
.relative(
|
||||
path.dirname(sourceFile),
|
||||
removeExt
|
||||
@@ -26,5 +26,9 @@ export function toImportSpecifier(
|
||||
)
|
||||
.replaceAll(path.sep, '/');
|
||||
|
||||
if (removeExt && importPath.endsWith('/index')) {
|
||||
importPath = importPath.slice(0, -'/index'.length);
|
||||
}
|
||||
|
||||
return importPath.startsWith('../') ? importPath : `./${importPath}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user