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:
Bartosz Kaszubowski 2020-09-25 23:25:19 +02:00 committed by GitHub
parent 8bed33b81f
commit c0d8238c49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 10 deletions

View file

@ -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)) {

View file

@ -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;