Skip to content

Commit 3e6727b

Browse files
authored
[Timeline] Escape quotes in names for injection in JSON-like object (#52)
Some features now have double quotes in their names, which must be escaped for integration in the JS script of the timeline page.
1 parent 74715ec commit 3e6727b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.eleventy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ export default function (eleventyConfig) {
246246
return name.replace(/</g, "&lt;").replace(/>/g, "&gt;");
247247
});
248248

249+
eleventyConfig.addShortcode("escapeJSON", function (name) {
250+
return name.replace(/"/g, "\\\"");
251+
});
252+
249253
eleventyConfig.addShortcode("baselineDate", function (dateStr) {
250254
const isBefore = dateStr.startsWith("≤");
251255
if (isBefore) {

site/timeline.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ layout: layout.njk
1414
{% if feature.status.baseline_low_date %}
1515
{
1616
feature: "{{ feature.id }}",
17-
name: "{% prettyFeatureName feature.name %}",
17+
name: "{% escapeJSON feature.name %}",
1818
baseline_low_date: "{{ feature.status.baseline_low_date }}"
1919
},
2020
{% endif %}

0 commit comments

Comments
 (0)