mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-17 08:37:57 +02:00
Initial work
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
parent
1b0acc5547
commit
6d3d416f58
5 changed files with 15 additions and 9 deletions
|
@ -5,6 +5,7 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable camelcase */
|
||||||
// eslint-disable-next-line spaced-comment
|
// eslint-disable-next-line spaced-comment
|
||||||
/// <reference types="@docusaurus/module-type-aliases" />
|
/// <reference types="@docusaurus/module-type-aliases" />
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,9 @@ function selectPluralMessage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePluralForm() {
|
export function usePluralForm(): {
|
||||||
|
selectMessage: (count: number, pluralMessages: string) => string;
|
||||||
|
} {
|
||||||
const localePluralForm = useLocalePluralForms();
|
const localePluralForm = useLocalePluralForms();
|
||||||
return {
|
return {
|
||||||
selectMessage: (count: number, pluralMessages: string): string => {
|
selectMessage: (count: number, pluralMessages: string): string => {
|
||||||
|
|
|
@ -35,7 +35,7 @@ export const logValidationBugReportHint = (): void => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function printWarning(warning?: Joi.ValidationError) {
|
export function printWarning(warning?: Joi.ValidationError): void {
|
||||||
if (warning) {
|
if (warning) {
|
||||||
const warningMessages = warning.details
|
const warningMessages = warning.details
|
||||||
.map(({message}) => message)
|
.map(({message}) => message)
|
||||||
|
|
|
@ -36,17 +36,17 @@ export function createExcerpt(fileString: string): string | undefined {
|
||||||
// Remove HTML tags.
|
// Remove HTML tags.
|
||||||
.replace(/<[^>]*>/g, '')
|
.replace(/<[^>]*>/g, '')
|
||||||
// Remove Title headers
|
// Remove Title headers
|
||||||
.replace(/^\#\s*([^#]*)\s*\#?/gm, '')
|
.replace(/^#\s*([^#]*)\s*#?/gm, '')
|
||||||
// Remove Markdown + ATX-style headers
|
// Remove Markdown + ATX-style headers
|
||||||
.replace(/^\#{1,6}\s*([^#]*)\s*(\#{1,6})?/gm, '$1')
|
.replace(/^#{1,6}\s*([^#]*)\s*(#{1,6})?/gm, '$1')
|
||||||
// Remove emphasis and strikethroughs.
|
// Remove emphasis and strikethroughs.
|
||||||
.replace(/([\*_~]{1,3})(\S.*?\S{0,1})\1/g, '$2')
|
.replace(/([*_~]{1,3})(\S.*?\S{0,1})\1/g, '$2')
|
||||||
// Remove images.
|
// Remove images.
|
||||||
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
|
.replace(/!\[(.*?)\][[(].*?[\])]/g, '$1')
|
||||||
// Remove footnotes.
|
// Remove footnotes.
|
||||||
.replace(/\[\^.+?\](\: .*?$)?/g, '')
|
.replace(/\[\^.+?\](: .*?$)?/g, '')
|
||||||
// Remove inline links.
|
// Remove inline links.
|
||||||
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
|
.replace(/\[(.*?)\][[(].*?[\])]/g, '$1')
|
||||||
// Remove inline code.
|
// Remove inline code.
|
||||||
.replace(/`(.+?)`/g, '$1')
|
.replace(/`(.+?)`/g, '$1')
|
||||||
// Remove blockquotes.
|
// Remove blockquotes.
|
||||||
|
|
|
@ -29,7 +29,10 @@ export function getDefaultLocaleConfig(locale: string): I18nLocaleConfig {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function shouldWarnAboutNodeVersion(version: number, locales: string[]) {
|
export function shouldWarnAboutNodeVersion(
|
||||||
|
version: number,
|
||||||
|
locales: string[],
|
||||||
|
): boolean {
|
||||||
const isOnlyEnglish = locales.length === 1 && locales.includes('en');
|
const isOnlyEnglish = locales.length === 1 && locales.includes('en');
|
||||||
const isOlderNodeVersion = version < 14;
|
const isOlderNodeVersion = version < 14;
|
||||||
return isOlderNodeVersion && !isOnlyEnglish;
|
return isOlderNodeVersion && !isOnlyEnglish;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue