Skip to content

Commit 2896bd1

Browse files
author
Peter Bengtsson
authored
remove encodeEntities on featured link cards (github#33935)
1 parent 7af3333 commit 2896bd1

File tree

8 files changed

+16
-31
lines changed

8 files changed

+16
-31
lines changed

components/guides/ArticleCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export const ArticleCard = ({ tabIndex, card, typeLabel }: Props) => {
1717
className="d-flex col-12 col-md-4 pr-0 pr-md-6 pr-lg-8"
1818
>
1919
<Link className="no-underline d-flex flex-column py-3 border-bottom" href={card.href}>
20-
<h3 className="h4 color-fg-default mb-1" dangerouslySetInnerHTML={{ __html: card.title }} />
20+
<h3 className="h4 color-fg-default mb-1">{card.title}</h3>
2121
<div className="h6 text-uppercase" data-testid="article-card-type">
2222
{typeLabel}
2323
</div>
24-
<p className="color-fg-muted my-3" dangerouslySetInnerHTML={{ __html: card.intro }} />
24+
<p className="color-fg-muted my-3">{card.intro}</p>
2525
{card.topics.length > 0 && (
2626
<ul style={{ listStyleType: 'none' }}>
2727
{card.topics.map((topic) => {

components/landing/ArticleList.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,18 @@ export const ArticleList = ({
6262
title={
6363
!link.hideIntro && link.intro ? (
6464
<h3 className="f4" data-testid="link-with-intro-title">
65-
<span
66-
dangerouslySetInnerHTML={
67-
link.fullTitle ? { __html: link.fullTitle } : { __html: link.title }
68-
}
69-
/>
65+
<span>{link.fullTitle ? link.fullTitle : link.title}</span>
7066
</h3>
7167
) : (
72-
<span
73-
className="f4 text-bold d-block"
74-
data-testid="link-with-intro-title"
75-
dangerouslySetInnerHTML={
76-
link.fullTitle ? { __html: link.fullTitle } : { __html: link.title }
77-
}
78-
></span>
68+
<span className="f4 text-bold d-block" data-testid="link-with-intro-title">
69+
{link.fullTitle ? link.fullTitle : link.title}
70+
</span>
7971
)
8072
}
8173
>
8274
{!link.hideIntro && link.intro && (
8375
<TruncateLines as="p" maxLines={2} className="color-fg-muted mb-0 mt-1">
84-
<span
85-
data-testid="link-with-intro-intro"
86-
dangerouslySetInnerHTML={{ __html: link.intro }}
87-
/>
76+
<span data-testid="link-with-intro-intro">{link.intro}</span>
8877
</TruncateLines>
8978
)}
9079
{link.date && (

components/landing/CodeExampleCard.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ export const CodeExampleCard = ({ example }: Props) => {
1414
href={`https://github.com/${example.href}`}
1515
>
1616
<div className="p-4">
17-
<h3 className="f4" dangerouslySetInnerHTML={{ __html: example.title }} />
18-
<p
19-
className="mt-2 mb-4 color-fg-muted"
20-
dangerouslySetInnerHTML={{ __html: example.description }}
21-
/>
17+
<h3 className="f4">{example.title}</h3>
18+
<p className="mt-2 mb-4 color-fg-muted">{example.description}</p>
2219
<div className="d-flex flex-wrap">
2320
{example.tags.map((tag) => {
2421
return (

components/landing/GuideCard.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ export const GuideCard = ({ guide }: Props) => {
1313
className="Box color-shadow-medium height-full d-block hover-shadow-large no-underline color-fg-default p-5"
1414
href={guide.href}
1515
>
16-
<h3 className="f2" dangerouslySetInnerHTML={{ __html: guide.title }} />
17-
<p
18-
className="mt-2 mb-4 color-fg-muted"
19-
dangerouslySetInnerHTML={{ __html: guide.intro || '' }}
20-
/>
16+
<h3 className="f2">{guide.title}</h3>
17+
<p className="mt-2 mb-4 color-fg-muted">{guide.intro || ''}</p>
2118

2219
<footer className="d-flex">
2320
<div>{authorString}</div>

lib/get-link-data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default async (
2525
}
2626

2727
async function processLink(link, context, option) {
28-
const opts = { textOnly: true, encodeEntities: true }
28+
const opts = { textOnly: true }
2929
// Parse the link in case it includes Liquid conditionals
3030
const linkPath = await renderContent(link.href || link, context, opts)
3131
if (!linkPath) return null

lib/process-learning-tracks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import getApplicableVersions from './get-applicable-versions.js'
44
import { getDataByLanguage } from './get-data.js'
55
import { executeWithFallback } from './render-with-fallback.js'
66

7-
const renderOpts = { textOnly: true, encodeEntities: true }
7+
const renderOpts = { textOnly: true }
88

99
// This module returns an object that contains a single featured learning track
1010
// and an array of all the other learning tracks for the current version.

middleware/contextualizers/generic-toc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ async function getTocItems(node, context, opts) {
9898
if (page.rawIntro) {
9999
// The intro can contain Markdown even though it might not
100100
// contain any Liquid.
101+
// Deliberately don't use `textOnly:true` here because we intend
102+
// to display the intro, in a table of contents component,
103+
// with the HTML (dangerouslySetInnerHTML).
101104
intro = await page.renderProp('rawIntro', context)
102105
}
103106
}

middleware/featured-links.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default async function featuredLinks(req, res, next) {
3030
req.context,
3131
{
3232
textOnly: true,
33-
encodeEntities: true,
3433
}
3534
)
3635
const item = { title, href: req.context.page.featuredLinks[key][i].href }

0 commit comments

Comments
 (0)