mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-12 07:42:34 +02:00
feat(v2): extract site title formatter to theme-common util (#3838)
This commit is contained in:
parent
821a39bf2e
commit
21572ccd37
9 changed files with 32 additions and 23 deletions
|
@ -22,6 +22,8 @@ export {isDocsPluginEnabled} from './utils/docsUtils';
|
|||
|
||||
export {isSamePath} from './utils/pathUtils';
|
||||
|
||||
export {useTitleFormatter} from './utils/generalUtils';
|
||||
|
||||
export {
|
||||
useDocsPreferredVersion,
|
||||
useDocsPreferredVersionByPluginId,
|
||||
|
|
15
packages/docusaurus-theme-common/src/utils/generalUtils.ts
Normal file
15
packages/docusaurus-theme-common/src/utils/generalUtils.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
|
||||
export const useTitleFormatter = (title?: string | undefined) => {
|
||||
const {siteConfig = {}} = useDocusaurusContext();
|
||||
const {title: siteTitle, titleDelimiter = '|'} = siteConfig;
|
||||
return title && title.trim().length
|
||||
? `${title.trim()} ${titleDelimiter} ${siteTitle}`
|
||||
: siteTitle;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue