forked from web-platform-dx/web-features-explorer
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
152 lines (133 loc) · 4.75 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
const { HtmlBasePlugin } = await import("@11ty/eleventy");
import { computeBaseline } from "compute-baseline";
import { Compat } from "compute-baseline/browser-compat-data";
// Remove this hack once https://github.com/11ty/eleventy-dependency-tree-esm/issues/2 is solved.
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const pkg = require("./package.json");
const bcd = new Compat();
let all = [];
for (const feature of bcd.walk(["api", "css", "javascript", "html", "http", "svg", "mathml", "webassembly", "webdriver"],)) {
let baseline = false;
try {
baseline = JSON.parse(computeBaseline({compatKeys: [feature.id], withAncestors: false}).toJSON());
} catch (e) {
// TODO(calculation fails for some features)
}
// Ignore sub features
// JavaScript is more nested so don't ignore there
// Might need to redo this and ignore the trees less eagerly
if (feature.id.split(".").length > 3 && !feature.id.startsWith("javascript") || feature.id.includes('_') ) {
continue;
}
// Ignore Temporal for now
if (feature.id.includes("Temporal")) {
continue;
}
// Ignore iterables for now
// https://github.com/orgs/mdn/discussions/707
const iterableInterfaces = [
"AudioParamMap",
"CSSNumericArray",
"CSSStyleDeclaration",
"CSSTransformValue",
"CSSUnparsedValue",
"CustomStateSet",
"DOMTokenList",
"EventCounts",
"FileSystemDirectoryHandle",
"FontFaceSet",
"FormData",
"GPUSupportedFeatures",
"Headers",
"Highlight",
"HighlightRegistry",
"KeyboardLayoutMap",
"MIDIInputMap",
"MIDIOutputMap",
"MediaKeyStatusMap",
"NodeList",
"PaymentInstruments",
"ReadableStream",
"StylePropertyMapReadOnly",
"URLSearchParams",
"ViewTransitionTypeSet",
"WGSLLanguageFeatures",
"WorkletSharedStorage",
"XRAnchorSet",
"XRHand",
"XRInputSourceArray"
]
const iterableMembers = [
".@@asyncIterator", ".@@iterator",
".entries", ".forEach",
".get", ".has",
".keys", ".size",
".values", ".add",
".clear", ".delete"
];
if (iterableInterfaces.some(iface => feature.id.includes(iface))
&& iterableMembers.some(member => feature.id.endsWith(member))) {
continue;
}
// Look for missing MDN URLs
if (!feature.mdn_url) {
all.push({id: feature.id, compat: feature.data.__compat, status: baseline});
}
}
export default function (eleventyConfig) {
eleventyConfig.addPlugin(HtmlBasePlugin);
eleventyConfig.addPassthroughCopy("site/assets");
eleventyConfig.addGlobalData("versions", async () => {
return {
date: new Date().toLocaleDateString(),
bcd: pkg.devDependencies["@mdn/browser-compat-data"].replace('^', ''),
};
});
eleventyConfig.addGlobalData("allFeatures", async () => {
return all;
});
eleventyConfig.addGlobalData("baselineFeatures", async () => {
return all.filter(feature => feature.status.baseline === "high")
.sort((a, b) => new Date(b.status.baseline_high_date) -
new Date(a.status.baseline_high_date));
});
eleventyConfig.addGlobalData("recentBaselineFeatures", async () => {
return all.filter(feature => feature.status.baseline === "low")
.sort((a, b) => new Date(b.status.baseline_low_date) -
new Date(a.status.baseline_low_date));
});
eleventyConfig.addGlobalData("limitedFeatures", async () => {
return all.filter(feature => {
return feature.status.baseline === false;
}).sort((a, b) => Object.keys(b.status.support).length - Object.keys(a.status.support).length);
});
eleventyConfig.addGlobalData("freshFeatures", async () => {
return all.filter(feature => {
return feature.status.support.chrome > 119 || feature.status.support.firefox > 119 || feature.status.support.safari > 17;
}).sort((a, b) => new Date(b.status.baseline_low_date) -
new Date(a.status.baseline_low_date)).sort((a, b) => Object.keys(b.status.support).length - Object.keys(a.status.support).length);
});
eleventyConfig.addGlobalData("chromiumFeatures", async () => {
return all.filter(feature => {
return feature.status.support.chrome ;
}).sort((a, b) => b.status.support.chrome - a.status.support.chrome )
});
eleventyConfig.addGlobalData("geckoFeatures", async () => {
return all.filter(feature => {
return feature.status.support.firefox ;
}).sort((a, b) => b.status.support.firefox - a.status.support.firefox )
});
eleventyConfig.addGlobalData("webkitFeatures", async () => {
return all.filter(feature => {
return feature.status.support.safari ;
}).sort((a, b) => b.status.support.safari - a.status.support.safari )
});
return {
dir: {
input: "site",
output: "docs",
},
pathPrefix: "/web-docs-backlog/",
};
};