Skip to content

Commit 7d4812b

Browse files
JSON output for features
1 parent c582a06 commit 7d4812b

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.eleventy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ export default function (eleventyConfig) {
310310
return `~${(value * 100).toFixed(3)}%`;
311311
});
312312

313+
eleventyConfig.addFilter("stringify", (data) => {
314+
return JSON.stringify(data, null, " ", 2)
315+
})
316+
313317
eleventyConfig.addGlobalData("versions", async () => {
314318
const { default: webFeaturesPackageJson } = await import(
315319
"./node_modules/web-features/package.json",

site/_includes/feature_full.njk

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535
{% include "wpt.njk" %}
3636

3737
<p class="edit-links">
38-
<a href="https://github.com/web-platform-dx/web-features/blob/main/features/{{ feature.id }}.yml">View the feature source file</a>
39-
<a href="https://github.com/web-platform-dx/web-features/blob/main/features/{{ feature.id }}.yml.dist">(dist)</a>
40-
-
41-
<a href="https://github.com/web-platform-dx/web-features/edit/main/features/{{ feature.id }}.yml">Edit the feature</a>
42-
-
43-
<a href="https://github.com/web-platform-dx/web-features/issues/new?title=[{{ feature.id }}] Issue title&body=Please describe the issue here...">Report an issue about this feature</a>
38+
<a href="../{{ feature.id | slugify }}.json">View as JSON</a>
39+
|
40+
<a href="https://github.com/web-platform-dx/web-features/edit/main/features/{{ feature.id }}.yml">Edit this feature</a>
41+
|
42+
<a href="https://github.com/web-platform-dx/web-features/issues/new?title=[{{ feature.id }}] Issue title&body=Please describe the issue here...">Report an issue</a>
43+
|
44+
Web-features entry:
45+
<a href="https://github.com/web-platform-dx/web-features/blob/main/features/{{ feature.id }}.yml">source</a>,
46+
<a href="https://github.com/web-platform-dx/web-features/blob/main/features/{{ feature.id }}.yml.dist">dist</a>
4447
</p>
4548
</div>

site/feature-json.njk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
pagination:
3+
data: allFeatures
4+
size: 1
5+
alias: feature
6+
permalink: "features/{{ feature.id | slugify }}.json"
7+
---
8+
{{ feature | stringify | safe }}

0 commit comments

Comments
 (0)