Skip to content

Commit

Permalink
fix(core): add custom path for component
Browse files Browse the repository at this point in the history
  • Loading branch information
why520crazy committed Dec 27, 2023
1 parent 6436122 commit 87954ae
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/configuration/front-matter.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ toc: menu
- 类型:`string`
- 默认:`文件夹名、文件名`

频道、页面的路由,默认会使用`paramCase`命名转换文件夹名或者文件名,文档实际访问路由会带上分类和频道的 path。
频道、页面、组件的路由,默认会使用`paramCase`命名转换文件夹名或者文件名,文档实际访问路由会带上分类和频道的 path。

## hidden
- 类型:`boolean`
Expand Down
2 changes: 1 addition & 1 deletion docs/en-us/configuration/front-matter.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The sorting of channels, categories, pages or components, is in ascending order
- Type: `string`
- Default: `folder name, file name`

The routing of the channel or page, will use `paramCase` nomenclature to convert the folder name or file name by default, the actual access route of the document will bring the path of the category and channel.
The routing of the channel or page or component, will use `paramCase` nomenclature to convert the folder name or file name by default, the actual access route of the document will bring the path of the category and channel.

## hidden
- Type: `boolean`
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/builders/library-component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,21 @@ describe('#library-component', () => {
await component.build();
expect(component.examples[0].standalone).toBeTruthy();
});

it('should custom component path', async () => {
const docContent = `---
title: New Button
path: button-path
---
This is button`;
await writeFilesToHost(context.host, {
[`${buttonDirPath}/doc/en-us.md`]: docContent
});
const component = new LibraryComponentImpl(context, library, 'button', `${DEFAULT_TEST_ROOT_PATH}/alib/button`);
await component.build();
const docItem = component.getDocItem('en-us');
expect(docItem.path).toEqual('button-path');
});
});

describe('api-docs', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/builders/library-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export class LibraryComponentImpl extends FileEmitter implements LibraryComponen
id: this.name,
title,
subtitle,
path: this.name,
path: this.meta.path || this.name,
importSpecifier: `${this.lib.name}/${this.name}`,
examples: this.examples.map(example => example.key),
overview: overviewSourceFile && overviewSourceFile.output ? true : false,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DocItemToc, HeadingLink, HomeDocMeta } from '../interfaces';
export interface ComponentDocMeta {
title?: string;
name?: string;
path?: string;
category?: string;
subtitle?: string;
description?: string;
Expand Down

0 comments on commit 87954ae

Please sign in to comment.