Skip to content

Commit

Permalink
πŸ”Ž SEO - Fix Page Titles (#1347)
Browse files Browse the repository at this point in the history
fix page titles
  • Loading branch information
Aibono1225 committed May 20, 2024
1 parent 48308e8 commit f4ae767
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/helpers/wrapPageElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ const wrapPageElement = ({ element, props }) => {
? props.data.markdownRemark
: null;

const isHomePage = props.path === '/';
const getTitleFromPath = (path) => {
const titles = {
'/': siteConfig.homepageTitle,
'/orphaned/': 'Orphaned Rules',
'/archived/': 'Archived Rules',
'/profile/': 'Profile',
};

return titles[path] || siteConfig.breadcrumbDefault;
};

const pageTitle = markdown
? markdown.frontmatter.title
: getTitleFromPath(props.path);

return (
//<Transition {...props}>
<Layout
{...props}
crumbLocation={props.location}
crumbLabel={
markdown
? markdown.frontmatter.title
: isHomePage
? siteConfig.homepageTitle
: siteConfig.breadcrumbDefault
}
crumbLabel={pageTitle}
seoDescription={markdown?.frontmatter?.seoDescription}
displayActions={markdown ? true : false}
ruleUri={markdown ? markdown.parent.relativePath : null}
Expand Down

0 comments on commit f4ae767

Please sign in to comment.