Browse Source

[Beta] Add React to <title>

main
Dan Abramov 2 years ago
parent
commit
af255ea9d6
  1. 2
      beta/src/components/Layout/Page.tsx
  2. 6
      beta/src/components/Seo.tsx

2
beta/src/components/Layout/Page.tsx

@ -56,7 +56,7 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
<div className="lg:hidden h-16 mb-2" />
<article className="break-words" key={asPath}>
<div className="pl-0">
<Seo title={title} />
<Seo title={title} isHomePage={isHomePage} />
{!isHomePage && (
<PageHeading
title={title}

6
beta/src/components/Seo.tsx

@ -12,6 +12,7 @@ export interface SeoProps {
image?: string;
// jsonld?: JsonLDType | Array<JsonLDType>;
children?: React.ReactNode;
isHomePage: boolean;
}
export const Seo = withRouter(
@ -21,13 +22,16 @@ export const Seo = withRouter(
image = '/logo-og.png',
router,
children,
isHomePage,
}: SeoProps & {router: Router}) => (
<Head>
{/* DEFAULT */}
<meta name="viewport" content="width=device-width, initial-scale=1" />
{title != null && <title key="title">{title}</title>}
{title != null && (
<title key="title">{title + (isHomePage ? '' : ' • React')}</title>
)}
{description != null && (
<meta name="description" key="description" content={description} />
)}

Loading…
Cancel
Save