From e295e9914b27f6ce46c29654a427c130d93ace89 Mon Sep 17 00:00:00 2001 From: cipchk Date: Sun, 31 Dec 2023 22:05:24 +0800 Subject: [PATCH 1/2] chore: fix site --- src/app/shared/components/docs/docs.component.ts | 11 ++++++++++- src/styles/_markdown.less | 6 ++++-- src/typings.d.ts | 5 ----- 3 files changed, 14 insertions(+), 8 deletions(-) delete mode 100644 src/typings.d.ts diff --git a/src/app/shared/components/docs/docs.component.ts b/src/app/shared/components/docs/docs.component.ts index 5652af188f..164a345ac3 100644 --- a/src/app/shared/components/docs/docs.component.ts +++ b/src/app/shared/components/docs/docs.component.ts @@ -18,6 +18,7 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; import { I18NService, MetaService } from '@core'; import { EditButtonComponent } from '../edit-button/edit-button.component'; +import { RouteTransferDirective } from '../route-transfer/route-transfer.directive'; declare var hljs: any; @@ -25,7 +26,15 @@ declare var hljs: any; selector: 'app-docs', templateUrl: './docs.component.html', standalone: true, - imports: [I18nPipe, NzAffixModule, NzAnchorModule, NzAlertModule, NzToolTipModule, EditButtonComponent] + imports: [ + I18nPipe, + RouteTransferDirective, + NzAffixModule, + NzAnchorModule, + NzAlertModule, + NzToolTipModule, + EditButtonComponent + ] }) export class DocsComponent implements OnInit, OnDestroy { private i18NChange$: Subscription; diff --git a/src/styles/_markdown.less b/src/styles/_markdown.less index 15ffeab60e..47f971ce8c 100644 --- a/src/styles/_markdown.less +++ b/src/styles/_markdown.less @@ -268,8 +268,6 @@ } .markdown.api-container { - overflow-x: auto; - table { table-layout: auto; min-width: 720px; @@ -325,6 +323,10 @@ hr { margin: 12px 0; } + + @media (max-width: @site-mobile) { + overflow-x: auto; + } } @demo-grid-color: #0092ff; diff --git a/src/typings.d.ts b/src/typings.d.ts deleted file mode 100644 index ef5c7bd620..0000000000 --- a/src/typings.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* SystemJS module definition */ -declare var module: NodeModule; -interface NodeModule { - id: string; -} From c4028554736ad729b11f6d81eebcb0ff30b6e719 Mon Sep 17 00:00:00 2001 From: cipchk Date: Mon, 1 Jan 2024 15:46:53 +0800 Subject: [PATCH 2/2] chore: add api type --- .vscode/launch.json | 4 +-- packages/abc/auto-focus/index.en-US.md | 2 +- packages/abc/auto-focus/index.zh-CN.md | 2 +- scripts/site/utils/generate-md.ts | 16 +++++++---- scripts/site/utils/utils.ts | 20 ++++++++++--- src/styles/_markdown.less | 39 ++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 15 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7513dd334d..827d61d18b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,9 +17,8 @@ "request": "launch", "name": "site generate", "runtimeArgs": ["-r", "ts-node/register", "-r", "tsconfig-paths/register"], - "protocol": "inspector", "internalConsoleOptions": "openOnSessionStart", - "args": ["${workspaceFolder}/scripts/site/generate.ts", "getting-started"], + "args": ["${workspaceFolder}/scripts/site/generate.ts", "auto-focus"], "env": { "TS_NODE_PROJECT": "${workspaceFolder}/scripts/site/tsconfig.json", "TS_NODE_TRANSPILE_ONLY": "true" @@ -31,7 +30,6 @@ "name": "schematics test", "runtimeArgs": ["-r", "ts-node/register"], "cwd": "${workspaceRoot}", - "protocol": "inspector", "sourceMaps": true, "internalConsoleOptions": "openOnSessionStart", "env": { diff --git a/packages/abc/auto-focus/index.en-US.md b/packages/abc/auto-focus/index.en-US.md index 69e1f6b5da..6d63fa905e 100644 --- a/packages/abc/auto-focus/index.en-US.md +++ b/packages/abc/auto-focus/index.en-US.md @@ -10,7 +10,7 @@ Allows to focus HTML-element right after its appearance, By default, it will tak ## API -### [auto-focus] +### [auto-focus]:standalone | Property | Description | Type | Default | |----------|-------------|------|---------| diff --git a/packages/abc/auto-focus/index.zh-CN.md b/packages/abc/auto-focus/index.zh-CN.md index cf54a290bb..b9088c2d80 100644 --- a/packages/abc/auto-focus/index.zh-CN.md +++ b/packages/abc/auto-focus/index.zh-CN.md @@ -10,7 +10,7 @@ module: import { AutoFocusModule } from '@delon/abc/auto-focus'; ## API -### [auto-focus] +### [auto-focus]:standalone | 成员 | 说明 | 类型 | 默认值 | |----|----|----|-----| diff --git a/scripts/site/utils/generate-md.ts b/scripts/site/utils/generate-md.ts index 81ae17170c..23e20fa624 100755 --- a/scripts/site/utils/generate-md.ts +++ b/scripts/site/utils/generate-md.ts @@ -20,15 +20,19 @@ const converters = [highlight()].concat([ (node: any) => { const tagName = JsonML.getTagName(node) as string; const children = JsonML.getChildren(node); - const sluggedId = generateSluggedId(children).id; + const sluggedData = generateSluggedId(children); // # - const childrenHtml = children.map(toHtml).join(''); + // const childrenHtml = children.map(toHtml).join(''); // const goTo = tagName === 'h2' ? `#` : ''; + const apiTypes = ['directive', 'standalone', 'service', 'class'] + .filter(key => (sluggedData as any)[key] === true) + .map(w => ``) + .join(''); const copy = /h[0-9]{1}/g.test(tagName) && +tagName.substring(1) > 1 - ? `` + ? `` : ``; - return `<${tagName} id="${sluggedId}">${copy}${childrenHtml}`; + return `<${tagName} id="${sluggedData.id}">${copy}${sluggedData.id}${apiTypes}`; } ], [ @@ -54,7 +58,7 @@ const converters = [highlight()].concat([ ], [ (node: any) => JsonML.isElement(node) && JsonML.getTagName(node) === 'a', - (node: any, index: number) => { + (node: any, _: number) => { const attrs = { ...JsonML.getAttributes(node) }; let target = attrs.href.startsWith('//') || attrs.href.startsWith('http') ? ' target="_blank"' : ''; if (~attrs.href.indexOf('ng-alain.com')) target = ''; @@ -65,7 +69,7 @@ const converters = [highlight()].concat([ ], [ (node: any) => !Array.isArray(node), - (node: any, index: number) => { + (node: any, _: number) => { if (!node.url) return ''; return ``; } diff --git a/scripts/site/utils/utils.ts b/scripts/site/utils/utils.ts index 0364686cb9..6dffd7c6ff 100755 --- a/scripts/site/utils/utils.ts +++ b/scripts/site/utils/utils.ts @@ -41,7 +41,14 @@ export function genValidId(id: string): string { return id.replace(/[() `?]*/g, ''); } -export function generateSluggedId(children: any): { id: string; text: string } { +export function generateSluggedId(children: any): { + id: string; + text: string; + directive: boolean; + standalone: boolean; + service: boolean; + class: boolean; +} { const headingText = children .map((node: any) => { if (JsonML.isElement(node)) { @@ -52,10 +59,15 @@ export function generateSluggedId(children: any): { id: string; text: string } { } return node; }) - .join(''); + .join('') + .trim(); return { - id: genValidId(headingText.trim()), - text: headingText + id: genValidId(headingText).split(':')[0], + text: headingText, + directive: children.some((node: any) => JsonML.isElement(node)), + standalone: headingText.includes(':standalone'), + service: headingText.includes(':service'), + class: headingText.includes(':class') }; } diff --git a/src/styles/_markdown.less b/src/styles/_markdown.less index 47f971ce8c..a2d4f113b6 100644 --- a/src/styles/_markdown.less +++ b/src/styles/_markdown.less @@ -499,3 +499,42 @@ margin-top: 40px; } } + +label.api-type-label { + display: inline; + margin-left: 8px; + padding: 1px 10px; + font-size: 12px; + font-weight: 400; + line-height: 18px; + color: #ffffffd9; + text-transform: uppercase; + vertical-align: middle; + border-radius: 2px; + + &.component { + color: @primary-color; + border: 2px solid @primary-color + } + + &.standalone { + color: @warning-color; + border: 2px solid @warning-color + } + + &.directive { + color: @magenta-6; + border: 2px solid @magenta-6 + } + + &.service { + color: @success-color; + border: 2px solid @success-color + } + + &.class { + color: @volcano-6; + border: 2px solid @volcano-6 + } + +}