From 1a32b39f78c88f8854b61d4eea3062fa1ec7517f Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 12 Jan 2023 17:57:34 +0100 Subject: [PATCH 1/2] don't htmlencode 'title' (#33920) --- components/context/ArticleContext.tsx | 2 +- components/context/AutomatedPageContext.tsx | 2 +- components/context/TocLandingContext.tsx | 2 +- lib/page.js | 4 ---- middleware/render-page.js | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/components/context/ArticleContext.tsx b/components/context/ArticleContext.tsx index 145b837708..324cd01c86 100644 --- a/components/context/ArticleContext.tsx +++ b/components/context/ArticleContext.tsx @@ -62,7 +62,7 @@ export const getArticleContextFromRequest = (req: any): ArticleContextT => { } return { - title: page.titlePlainText, + title: page.title, intro: page.intro, effectiveDate: page.effectiveDate || '', renderedPage: req.context.renderedPage || '', diff --git a/components/context/AutomatedPageContext.tsx b/components/context/AutomatedPageContext.tsx index 1810027294..79a0093a73 100644 --- a/components/context/AutomatedPageContext.tsx +++ b/components/context/AutomatedPageContext.tsx @@ -28,7 +28,7 @@ export const getAutomatedPageContextFromRequest = (req: any): AutomatedPageConte const page = req.context.page return { - title: page.titlePlainText, + title: page.title, intro: page.intro, renderedPage: req.context.renderedPage || '', miniTocItems: req.context.miniTocItems || [], diff --git a/components/context/TocLandingContext.tsx b/components/context/TocLandingContext.tsx index 8fe21595ec..dfcfa57f02 100644 --- a/components/context/TocLandingContext.tsx +++ b/components/context/TocLandingContext.tsx @@ -34,7 +34,7 @@ export const useTocLandingContext = (): TocLandingContextT => { export const getTocLandingContextFromRequest = (req: any): TocLandingContextT => { return { - title: req.context.page.titlePlainText, + title: req.context.page.title, productCallout: req.context.page.product || '', introPlainText: req.context.page.introPlainText, tocItems: (req.context.genericTocFlat || req.context.genericTocNested || []).map((obj: any) => diff --git a/lib/page.js b/lib/page.js index 75cac9b6d4..5fc94efb21 100644 --- a/lib/page.js +++ b/lib/page.js @@ -178,10 +178,6 @@ class Page { }) this.title = await renderContentWithFallback(this, 'rawTitle', context, { textOnly: true, - encodeEntities: true, - }) - this.titlePlainText = await renderContentWithFallback(this, 'rawTitle', context, { - textOnly: true, }) this.shortTitle = await renderContentWithFallback(this, 'shortTitle', context, { textOnly: true, diff --git a/middleware/render-page.js b/middleware/render-page.js index 6a65e9ba99..98a14dd80d 100644 --- a/middleware/render-page.js +++ b/middleware/render-page.js @@ -81,7 +81,7 @@ export default async function renderPage(req, res) { if (isConnectionDropped(req, res)) return // Create string for tag - page.fullTitle = page.titlePlainText + page.fullTitle = page.title // add localized ` - GitHub Docs` suffix to <title> tag (except for the homepage) if (!patterns.homepagePath.test(path)) { From 35cf066d00ce3f6a2e8bdad1437cd75cee705692 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson <peterbe@github.com> Date: Thu, 12 Jan 2023 18:01:59 +0100 Subject: [PATCH 2/2] ToC landing pages should display HTML in intro (#33916) --- components/context/TocLandingContext.tsx | 4 ++-- components/landing/TocLanding.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/context/TocLandingContext.tsx b/components/context/TocLandingContext.tsx index dfcfa57f02..054134e03d 100644 --- a/components/context/TocLandingContext.tsx +++ b/components/context/TocLandingContext.tsx @@ -11,7 +11,7 @@ export type TocItem = { export type TocLandingContextT = { title: string - introPlainText: string + intro: string productCallout: string tocItems: Array<TocItem> variant?: 'compact' | 'expanded' @@ -36,7 +36,7 @@ export const getTocLandingContextFromRequest = (req: any): TocLandingContextT => return { title: req.context.page.title, productCallout: req.context.page.product || '', - introPlainText: req.context.page.introPlainText, + intro: req.context.page.intro, tocItems: (req.context.genericTocFlat || req.context.genericTocNested || []).map((obj: any) => pick(obj, ['fullPath', 'title', 'intro', 'childTocItems']) ), diff --git a/components/landing/TocLanding.tsx b/components/landing/TocLanding.tsx index 3058c079eb..cfa4349f4d 100644 --- a/components/landing/TocLanding.tsx +++ b/components/landing/TocLanding.tsx @@ -18,7 +18,7 @@ export const TocLanding = () => { const router = useRouter() const { title, - introPlainText, + intro, tocItems, productCallout, variant, @@ -39,7 +39,7 @@ export const TocLanding = () => { <ArticleGridLayout> <ArticleTitle>{title}</ArticleTitle> - {introPlainText && <Lead data-search="lead">{introPlainText}</Lead>} + {intro && <Lead data-search="lead">{intro}</Lead>} {productCallout && ( <Callout variant="success" dangerouslySetInnerHTML={{ __html: productCallout }} />