mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 22:17:00 +02:00
feat(v2): add ability to set custom title delimiter in config (#3460)
* feat(v2): add custom title delimiter to the theme classic * fix validation tests * remove title delimiter fallback * move titleDelimiter to main config, update theme-bootstrap * remove test value from config * update test snapshot * Improve docs Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com>
This commit is contained in:
parent
8bed33b81f
commit
c0d8238c49
9 changed files with 38 additions and 10 deletions
|
@ -22,6 +22,7 @@ function Layout(props) {
|
|||
title: siteTitle,
|
||||
themeConfig: {image: defaultImage},
|
||||
url: siteUrl,
|
||||
titleDelimiter,
|
||||
} = siteConfig;
|
||||
const {
|
||||
children,
|
||||
|
@ -33,8 +34,9 @@ function Layout(props) {
|
|||
permalink,
|
||||
version,
|
||||
} = props;
|
||||
const metaTitle = title ? `${title} | ${siteTitle}` : siteTitle;
|
||||
|
||||
const metaTitle = title
|
||||
? `${title} ${titleDelimiter} ${siteTitle}`
|
||||
: siteTitle;
|
||||
const metaImage = image || defaultImage;
|
||||
let metaImageUrl = siteUrl + useBaseUrl(metaImage);
|
||||
if (!isInternalUrl(metaImage)) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
|
|||
|
||||
function DocItem(props) {
|
||||
const {siteConfig = {}} = useDocusaurusContext();
|
||||
const {url: siteUrl, title: siteTitle} = siteConfig;
|
||||
const {url: siteUrl, title: siteTitle, titleDelimiter} = siteConfig;
|
||||
const {content: DocContent} = props;
|
||||
const {metadata} = DocContent;
|
||||
const {description, title, permalink} = metadata;
|
||||
|
@ -22,7 +22,9 @@ function DocItem(props) {
|
|||
frontMatter: {image: metaImage, keywords},
|
||||
} = DocContent;
|
||||
|
||||
const metaTitle = title ? `${title} | ${siteTitle}` : siteTitle;
|
||||
const metaTitle = title
|
||||
? `${title} ${titleDelimiter} ${siteTitle}`
|
||||
: siteTitle;
|
||||
let metaImageUrl = siteUrl + useBaseUrl(metaImage);
|
||||
if (!isInternalUrl(metaImage)) {
|
||||
metaImageUrl = metaImage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue