From 13c2234a915817d47ee87dacc23e0577edc5bb40 Mon Sep 17 00:00:00 2001 From: khalilcodes Date: Thu, 24 Mar 2022 02:11:16 +0300 Subject: [PATCH] [site/pages,#94]: fix titles --- site/pages/_app.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/site/pages/_app.js b/site/pages/_app.js index 29bc809..6f7d55f 100644 --- a/site/pages/_app.js +++ b/site/pages/_app.js @@ -7,7 +7,6 @@ import { ThemeProvider } from 'next-themes' import '../styles/global.css' import siteConfig from '../config/siteConfig.js' import Layout from '../components/Layout' -import MdxPage from '../components/MDX' import * as gtag from '../lib/gtag' function MyApp({ Component, pageProps }) { @@ -26,14 +25,15 @@ function MyApp({ Component, pageProps }) { } // end Google Analytics - // console.log(Component) - // const pageTitle = ( - // router.pathname == "/" - // ? "home" - // // convert slug to title - // : router.pathname.split("/").pop().replace(/-/g, " ") - // ) // capitalize first char of each word - // .replace(/(^\w{1})|(\s{1}\w{1})/g, (str) => str.toUpperCase()); + const pageTitle = ( + // check if markdown page + Component.name == "Page" + ? pageProps.title ?? + // convert path to title + pageProps._raw.flattenedPath.split("/").pop().replace(/-/g, " ") + : Component.name + ) // capitalize first char of each word + .replace(/(^\w{1})|(\s{1}\w{1})/g, (str) => str.toUpperCase()); return ( @@ -66,7 +66,7 @@ function MyApp({ Component, pageProps }) { }} /> )} - +