-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gem-book] Support empty file fallback
Closed #149
- Loading branch information
Showing
12 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Use pattern create CRUD app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
isNav: true | ||
reverse: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { SupportLang } from '../common/config'; | ||
import type { GemBookElement } from '../element'; | ||
|
||
type Status = 'none' | 'partial'; | ||
|
||
const locales: Record<string, Record<Status, string>> = { | ||
en: { | ||
none: 'This document has not been translated', | ||
partial: 'This document is not translated', | ||
}, | ||
zh: { | ||
none: '该文档还未翻译', | ||
partial: '该文档部分未翻译', | ||
}, | ||
} satisfies Record<SupportLang, unknown>; | ||
|
||
customElements.whenDefined('gem-book').then(({ GemBookPluginElement }: typeof GemBookElement) => { | ||
const { Gem, Utils, selfI18n } = GemBookPluginElement; | ||
const { html, customElement, attribute } = Gem; | ||
|
||
@customElement('gbp-trans-status') | ||
class _GbpTransStatusElement extends GemBookPluginElement { | ||
@attribute status: Status; | ||
|
||
get #status() { | ||
return this.status || 'none'; | ||
} | ||
|
||
constructor() { | ||
super({ isLight: true }); | ||
} | ||
|
||
render() { | ||
const langPkg = locales[GemBookPluginElement.lang || selfI18n.fallbackLanguage]; | ||
return html`${Utils.parseMarkdown( | ||
`> [!WARNING] | ||
> ${langPkg[this.#status]} | ||
`, | ||
)}`; | ||
} | ||
} | ||
}); |