Skip to content

Commit

Permalink
[docs-infra][toolpad] Fix Page title and SERP title mismatch (#41919)
Browse files Browse the repository at this point in the history
  • Loading branch information
bharatkashyap authored May 16, 2024
1 parent f3be912 commit dc922ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
20 changes: 5 additions & 15 deletions docs/src/modules/components/AppLayoutDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ import { useRouter } from 'next/router';
import { styled } from '@mui/material/styles';
import { exactProp } from '@mui/utils';
import GlobalStyles from '@mui/material/GlobalStyles';
import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
import Head from 'docs/src/modules/components/Head';
import AppFrame from 'docs/src/modules/components/AppFrame';
import AppContainer from 'docs/src/modules/components/AppContainer';
import AppTableOfContents from 'docs/src/modules/components/AppTableOfContents';
import AdManager from 'docs/src/modules/components/AdManager';
import AppLayoutDocsFooter from 'docs/src/modules/components/AppLayoutDocsFooter';
import BackToTop from 'docs/src/modules/components/BackToTop';
import getProductInfoFromUrl from 'docs/src/modules/utils/getProductInfoFromUrl';
import {
AD_MARGIN_TOP,
AD_HEIGHT,
AD_HEIGHT_MOBILE,
AD_MARGIN_BOTTOM,
} from 'docs/src/modules/components/Ad';
import { convertProductIdToName } from 'docs/src/modules/components/AppSearch';

const TOC_WIDTH = 242;

Expand Down Expand Up @@ -119,20 +120,9 @@ export default function AppLayoutDocs(props) {
throw new Error('Missing description in the page');
}

const { canonicalAs } = pathnameToLanguage(router.asPath);
let productName = 'MUI';
if (canonicalAs.startsWith('/material-ui/')) {
productName = 'Material UI';
} else if (canonicalAs.startsWith('/base-ui/')) {
productName = 'Base UI';
} else if (canonicalAs.startsWith('/x/')) {
productName = 'MUI X';
} else if (canonicalAs.startsWith('/system/')) {
productName = 'MUI System';
} else if (canonicalAs.startsWith('/toolpad/')) {
productName = 'Toolpad';
} else if (canonicalAs.startsWith('/joy-ui/')) {
productName = 'Joy UI';
const productName = convertProductIdToName(getProductInfoFromUrl(router.asPath));
if (!productName) {
console.error('productName mapping missing for', router.asPath);
}

const Layout = disableLayout ? React.Fragment : AppFrame;
Expand Down
1 change: 1 addition & 0 deletions docs/src/modules/components/AppSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ const productNameProductId = {
toolpad: 'Toolpad',
'toolpad-studio': 'Toolpad Studio',
'toolpad-core': 'Toolpad Core',
'docs-infra': 'Docs Infra',
};

export function convertProductIdToName(productInfo) {
Expand Down

0 comments on commit dc922ee

Please sign in to comment.