Skip to content

Commit 2968873

Browse files
Add discouraged reason
1 parent 6582215 commit 2968873

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

.eleventy.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,31 @@ export default async function (eleventyConfig) {
124124

125125
eleventyConfig.addLiquidFilter("dateToRfc3339", feedPlugin.dateToRfc3339);
126126

127+
eleventyConfig.addFilter("prettyUrlForAdditionalDiscouragedInfo", function(value) {
128+
const ghPrefix = "https://github.com/";
129+
const w3cPrefix = "https://www.w3.org/";
130+
const csswgDraftPrefix = "https://drafts.csswg.org/";
131+
const htmlSpecPrefix = "https://html.spec.whatwg.org/multipage/";
132+
133+
if (value.startsWith(ghPrefix)) {
134+
return value.substring(ghPrefix.length) + " (GitHub)";
135+
}
136+
137+
if (value.startsWith(w3cPrefix)) {
138+
return value.substring(w3cPrefix.length) + " (W3C)";
139+
}
140+
141+
if (value.startsWith(csswgDraftPrefix)) {
142+
return value.substring(csswgDraftPrefix.length) + " (CSSWG draft)";
143+
}
144+
145+
if (value.startsWith(htmlSpecPrefix)) {
146+
return value.substring(htmlSpecPrefix.length) + " (HTML spec)";
147+
}
148+
149+
return value;
150+
})
151+
127152
eleventyConfig.addPassthroughCopy("site/assets");
128153
eleventyConfig.addPassthroughCopy({ "node_modules/apexcharts/dist/apexcharts.css": "assets/apexcharts.css" });
129154
eleventyConfig.addPassthroughCopy({ "node_modules/apexcharts/dist/apexcharts.min.js": "assets/apexcharts.js" });

site/_includes/discouraged.njk

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
{% if feature.discouraged %}
22
<div class="discouraged-info">
33
<p>
4-
This feature is discouraged.
5-
{% if feature.discouraged.alternatives %}
6-
Consider using
7-
{% for alternative in feature.discouraged.alternatives %}
8-
<a href="/features/{{ alternative }}">{{ allFeaturesAsObject[alternative].name }}</a>
9-
{% if not loop.last %}, {% endif %}
10-
{% endfor %}
11-
instead.
4+
<strong>This feature is discouraged</strong>
5+
{% if feature.discouraged.reason %}
6+
&mdash; {{ feature.discouraged.reason }}
127
{% endif %}
13-
For the rationale, see:
148
</p>
15-
<ul>
9+
{% if feature.discouraged.alternatives %}
10+
<p>
11+
Consider using
12+
{% for alternative in feature.discouraged.alternatives %}
13+
<a href="/features/{{ alternative }}">{{ allFeaturesAsObject[alternative].name }}</a>
14+
{% if not loop.last %}, {% endif %}
15+
{% endfor %}
16+
instead.
17+
</p>
18+
{% endif %}
19+
<p>For more information, see:
1620
{% for rationale in feature.discouraged.according_to %}
17-
<li><a href="{{ rationale }}">{{ rationale }}</a></li>
21+
<a href="{{ rationale }}">{{ rationale | prettyUrlForAdditionalDiscouragedInfo }}</a>
22+
{% if not loop.last %}, {% endif %}
1823
{% endfor %}
19-
</ul>
24+
</p>
2025
</div>
2126
{% endif %}

site/assets/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ a:hover {
384384
margin: 0;
385385
}
386386

387+
.feature-page .discouraged-info p:not(:last-child) {
388+
margin-block-end: .5rem;
389+
}
390+
387391
.feature-page .feature-box {
388392
background: var(--background-alt);
389393
padding: calc(var(--margin) / 2);

0 commit comments

Comments
 (0)