From cbe2a266e2a620c0911d01c73797a84430d26168 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 21 Mar 2023 01:06:14 +0000 Subject: [PATCH] Fix for Twitter --- src/components/Seo.tsx | 213 ++++++++++++++++++++--------------------- 1 file changed, 106 insertions(+), 107 deletions(-) diff --git a/src/components/Seo.tsx b/src/components/Seo.tsx index 1c5d48d7..e8517ee5 100644 --- a/src/components/Seo.tsx +++ b/src/components/Seo.tsx @@ -23,124 +23,123 @@ export const Seo = withRouter( router, children, isHomePage, - }: SeoProps & {router: Router}) => ( - - {/* DEFAULT */} + }: SeoProps & {router: Router}) => { + const pageTitle = isHomePage ? 'React' : title + ' – React'; + // Twitter's meta parser is not very good. + const twitterTitle = pageTitle.replace(/[<>]/g, ''); + return ( + + {/* DEFAULT */} - + - {title != null && ( - {title + (isHomePage ? '' : ' – React')} - )} - {description != null && ( - - )} - {/* + {title != null && {pageTitle}} + {description != null && ( + + )} + {/* @todo favicon */} - - {/* OPEN GRAPH */} - - - {title != null && ( + + {/* OPEN GRAPH */} + - )} - {description != null && ( + {title != null && ( + + )} + {description != null && ( + + )} + - )} - + {/* TWITTER */} + + + + {title != null && ( + + )} + {description != null && ( + + )} - {/* TWITTER */} - - - - {title != null && ( - )} - {description != null && ( - )} - - - - - - - - - - {children} - - ) + + + + + + + {children} + + ); + } );