mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
UI: update registry
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@fumadocs/cli': patch
|
||||
---
|
||||
|
||||
support layout type
|
||||
@@ -27,17 +27,17 @@ export const registry: Registry = {
|
||||
{
|
||||
type: 'components',
|
||||
path: 'components/sidebar/base.tsx',
|
||||
target: '<dir>/layout/sidebar/base.tsx',
|
||||
target: '<dir>/docs-sidebar/base.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
path: 'components/sidebar/page-tree.tsx',
|
||||
target: '<dir>/layout/sidebar/page-tree.tsx',
|
||||
target: '<dir>/docs-sidebar/page-tree.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
path: 'components/sidebar/link-item.tsx',
|
||||
target: '<dir>/layout/sidebar/link-item.tsx',
|
||||
target: '<dir>/docs-sidebar/link-item.tsx',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -46,14 +46,14 @@ export const registry: Registry = {
|
||||
unlisted: true,
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/shared/index.tsx',
|
||||
target: '<dir>/layout/shared/index.tsx',
|
||||
target: '<dir>/shared/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/shared/client.tsx',
|
||||
target: '<dir>/layout/shared/client.tsx',
|
||||
target: '<dir>/shared/client.tsx',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -61,24 +61,24 @@ export const registry: Registry = {
|
||||
name: 'layouts/docs',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/index.tsx',
|
||||
target: '<dir>/layout/docs/index.tsx',
|
||||
target: '<dir>/docs/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/client.tsx',
|
||||
target: '<dir>/layout/docs/client.tsx',
|
||||
target: '<dir>/docs/client.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/page/index.tsx',
|
||||
target: '<dir>/layout/docs/page/index.tsx',
|
||||
target: '<dir>/docs/page/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/page/client.tsx',
|
||||
target: '<dir>/layout/docs/page/client.tsx',
|
||||
target: '<dir>/docs/page/client.tsx',
|
||||
},
|
||||
],
|
||||
unlisted: true,
|
||||
@@ -87,19 +87,19 @@ export const registry: Registry = {
|
||||
name: 'layouts/flux',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/flux/index.tsx',
|
||||
target: '<dir>/layout/flux/index.tsx',
|
||||
target: '<dir>/flux/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/flux/page/index.tsx',
|
||||
target: '<dir>/layout/flux/page/index.tsx',
|
||||
target: '<dir>/flux/page/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/flux/page/client.tsx',
|
||||
target: '<dir>/layout/flux/page/client.tsx',
|
||||
target: '<dir>/flux/page/client.tsx',
|
||||
},
|
||||
],
|
||||
unlisted: true,
|
||||
@@ -108,24 +108,24 @@ export const registry: Registry = {
|
||||
name: 'layouts/notebook',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/index.tsx',
|
||||
target: '<dir>/layout/notebook/index.tsx',
|
||||
target: '<dir>/notebook/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/client.tsx',
|
||||
target: '<dir>/layout/notebook/client.tsx',
|
||||
target: '<dir>/notebook/client.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/page/index.tsx',
|
||||
target: '<dir>/layout/notebook/page/index.tsx',
|
||||
target: '<dir>/notebook/page/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/page/client.tsx',
|
||||
target: '<dir>/layout/notebook/page/client.tsx',
|
||||
target: '<dir>/notebook/page/client.tsx',
|
||||
},
|
||||
],
|
||||
unlisted: true,
|
||||
@@ -134,9 +134,9 @@ export const registry: Registry = {
|
||||
name: 'layouts/home',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/home/index.tsx',
|
||||
target: '<dir>/layout/home/index.tsx',
|
||||
target: '<dir>/home/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'ui',
|
||||
|
||||
@@ -6,7 +6,7 @@ export function createConfigSchema(isSrc: boolean) {
|
||||
const defaultAliases = {
|
||||
uiDir: './components/ui',
|
||||
componentsDir: './components',
|
||||
blockDir: './components',
|
||||
layoutDir: './layouts',
|
||||
cssDir: './styles',
|
||||
libDir: './lib',
|
||||
};
|
||||
@@ -24,7 +24,7 @@ export function createConfigSchema(isSrc: boolean) {
|
||||
.object({
|
||||
uiDir: z.string().default(defaultAliases.uiDir),
|
||||
componentsDir: z.string().default(defaultAliases.uiDir),
|
||||
blockDir: z.string().default(defaultAliases.blockDir),
|
||||
layoutDir: z.string().default(defaultAliases.layoutDir),
|
||||
cssDir: z.string().default(defaultAliases.componentsDir),
|
||||
libDir: z.string().default(defaultAliases.libDir),
|
||||
})
|
||||
|
||||
@@ -306,10 +306,10 @@ export class ComponentInstaller {
|
||||
const dir = (
|
||||
{
|
||||
components: config.aliases.componentsDir,
|
||||
block: config.aliases.blockDir,
|
||||
ui: config.aliases.uiDir,
|
||||
css: config.aliases.cssDir,
|
||||
lib: config.aliases.libDir,
|
||||
layout: config.aliases.layoutDir,
|
||||
route: './',
|
||||
} as const
|
||||
)[file.type];
|
||||
|
||||
@@ -14,20 +14,20 @@ export function pluginPreserveLayouts(): ComponentInstallerPlugin {
|
||||
];
|
||||
// original specifier -> new specifier
|
||||
const layoutComps: Record<string, string> = {
|
||||
'@/<dir>/layout/home/index.tsx': 'layouts/home',
|
||||
'@/<dir>/layout/shared/index.tsx': 'layouts/shared',
|
||||
'@/<dir>/layout/shared/client.tsx': 'layouts/shared',
|
||||
'@/<dir>/layout/notebook/index.tsx': 'layouts/notebook',
|
||||
'@/<dir>/layout/notebook/client.tsx': 'layouts/notebook',
|
||||
'@/<dir>/layout/notebook/page/index.tsx': 'layouts/notebook/page',
|
||||
'@/<dir>/layout/notebook/page/client.tsx': 'layouts/notebook/page',
|
||||
'@/<dir>/layout/docs/index.tsx': 'layouts/docs',
|
||||
'@/<dir>/layout/docs/client.tsx': 'layouts/docs',
|
||||
'@/<dir>/layout/docs/page/index.tsx': 'layouts/docs/page',
|
||||
'@/<dir>/layout/docs/page/client.tsx': 'layouts/docs/page',
|
||||
'@/<dir>/layout/flux/index.tsx': 'layouts/flux',
|
||||
'@/<dir>/layout/flux/page/index.tsx': 'layouts/flux/page',
|
||||
'@/<dir>/layout/flux/page/client.tsx': 'layouts/flux/page',
|
||||
'@/<dir>/home/index.tsx': 'layouts/home',
|
||||
'@/<dir>/shared/index.tsx': 'layouts/shared',
|
||||
'@/<dir>/shared/client.tsx': 'layouts/shared',
|
||||
'@/<dir>/notebook/index.tsx': 'layouts/notebook',
|
||||
'@/<dir>/notebook/client.tsx': 'layouts/notebook',
|
||||
'@/<dir>/notebook/page/index.tsx': 'layouts/notebook/page',
|
||||
'@/<dir>/notebook/page/client.tsx': 'layouts/notebook/page',
|
||||
'@/<dir>/docs/index.tsx': 'layouts/docs',
|
||||
'@/<dir>/docs/client.tsx': 'layouts/docs',
|
||||
'@/<dir>/docs/page/index.tsx': 'layouts/docs/page',
|
||||
'@/<dir>/docs/page/client.tsx': 'layouts/docs/page',
|
||||
'@/<dir>/flux/index.tsx': 'layouts/flux',
|
||||
'@/<dir>/flux/page/index.tsx': 'layouts/flux/page',
|
||||
'@/<dir>/flux/page/client.tsx': 'layouts/flux/page',
|
||||
};
|
||||
const layoutNameSet = new Set(layoutNames);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export type DownloadedRegistryInfo = z.output<typeof registryInfoSchema>;
|
||||
export type File = z.output<typeof fileSchema>;
|
||||
export type Component = z.output<typeof componentSchema>;
|
||||
|
||||
export const namespaces = ['components', 'lib', 'css', 'route', 'ui', 'block'] as const;
|
||||
export const namespaces = ['components', 'lib', 'css', 'route', 'ui', 'layout'] as const;
|
||||
|
||||
export const indexSchema = z.object({
|
||||
name: z.string(),
|
||||
|
||||
@@ -27,17 +27,17 @@ export const registry: Registry = {
|
||||
{
|
||||
type: 'components',
|
||||
path: 'components/sidebar/base.tsx',
|
||||
target: '<dir>/layout/sidebar/base.tsx',
|
||||
target: '<dir>/docs-sidebar/base.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
path: 'components/sidebar/page-tree.tsx',
|
||||
target: '<dir>/layout/sidebar/page-tree.tsx',
|
||||
target: '<dir>/docs-sidebar/page-tree.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
path: 'components/sidebar/link-item.tsx',
|
||||
target: '<dir>/layout/sidebar/link-item.tsx',
|
||||
target: '<dir>/docs-sidebar/link-item.tsx',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -46,14 +46,14 @@ export const registry: Registry = {
|
||||
unlisted: true,
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/shared/index.tsx',
|
||||
target: '<dir>/layout/shared/index.tsx',
|
||||
target: '<dir>/shared/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/shared/client.tsx',
|
||||
target: '<dir>/layout/shared/client.tsx',
|
||||
target: '<dir>/shared/client.tsx',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -61,24 +61,24 @@ export const registry: Registry = {
|
||||
name: 'layouts/docs',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/index.tsx',
|
||||
target: '<dir>/layout/docs/index.tsx',
|
||||
target: '<dir>/docs/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/client.tsx',
|
||||
target: '<dir>/layout/docs/client.tsx',
|
||||
target: '<dir>/docs/client.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/page/index.tsx',
|
||||
target: '<dir>/layout/docs/page/index.tsx',
|
||||
target: '<dir>/docs/page/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/docs/page/client.tsx',
|
||||
target: '<dir>/layout/docs/page/client.tsx',
|
||||
target: '<dir>/docs/page/client.tsx',
|
||||
},
|
||||
],
|
||||
unlisted: true,
|
||||
@@ -87,19 +87,19 @@ export const registry: Registry = {
|
||||
name: 'layouts/flux',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/flux/index.tsx',
|
||||
target: '<dir>/layout/flux/index.tsx',
|
||||
target: '<dir>/flux/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/flux/page/index.tsx',
|
||||
target: '<dir>/layout/flux/page/index.tsx',
|
||||
target: '<dir>/flux/page/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/flux/page/client.tsx',
|
||||
target: '<dir>/layout/flux/page/client.tsx',
|
||||
target: '<dir>/flux/page/client.tsx',
|
||||
},
|
||||
],
|
||||
unlisted: true,
|
||||
@@ -108,24 +108,24 @@ export const registry: Registry = {
|
||||
name: 'layouts/notebook',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/index.tsx',
|
||||
target: '<dir>/layout/notebook/index.tsx',
|
||||
target: '<dir>/notebook/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/client.tsx',
|
||||
target: '<dir>/layout/notebook/client.tsx',
|
||||
target: '<dir>/notebook/client.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/page/index.tsx',
|
||||
target: '<dir>/layout/notebook/page/index.tsx',
|
||||
target: '<dir>/notebook/page/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/notebook/page/client.tsx',
|
||||
target: '<dir>/layout/notebook/page/client.tsx',
|
||||
target: '<dir>/notebook/page/client.tsx',
|
||||
},
|
||||
],
|
||||
unlisted: true,
|
||||
@@ -134,9 +134,9 @@ export const registry: Registry = {
|
||||
name: 'layouts/home',
|
||||
files: [
|
||||
{
|
||||
type: 'components',
|
||||
type: 'layout',
|
||||
path: 'layouts/home/index.tsx',
|
||||
target: '<dir>/layout/home/index.tsx',
|
||||
target: '<dir>/home/index.tsx',
|
||||
},
|
||||
{
|
||||
type: 'ui',
|
||||
|
||||
@@ -27,16 +27,21 @@ export async function findSlotComponents(dir: string): Promise<Component[]> {
|
||||
const slots: Component[] = [];
|
||||
|
||||
for await (const file of glob('layouts/**/slots/*', { cwd: dir })) {
|
||||
const name = path.relative('layouts', file);
|
||||
const relativePath = path.relative('layouts', file);
|
||||
const name = relativePath
|
||||
.split(path.sep)
|
||||
.filter((v) => v !== 'slots')
|
||||
.join('/')
|
||||
.slice(0, -path.extname(relativePath).length);
|
||||
|
||||
slots.push({
|
||||
name: name.slice(0, -path.extname(name).length),
|
||||
name: `slots/${name}`,
|
||||
unlisted: true,
|
||||
files: [
|
||||
{
|
||||
path: file,
|
||||
type: 'components',
|
||||
target: path.join('<dir>/layout', name),
|
||||
type: 'layout',
|
||||
target: path.join('<dir>', relativePath),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user