Skip to content

Commit

Permalink
Drop $schema property from lists + legacy IDs (#4)
Browse files Browse the repository at this point in the history
* Drop schemas

* Remove `$schema` from legacy ids

* Update src/util/getList.js

Co-authored-by: Matt Cowley <[email protected]>

* Linting

Co-authored-by: Matt Cowley <[email protected]>
  • Loading branch information
A5rocks and MattIPv4 authored Aug 21, 2022
1 parent d59c1c5 commit bf4b077
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/routes/legacy-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
handler: () => {
// Get legacy IDs and sort
const map = Object.entries(legacy)
.filter((k) => k[0] !== '$schema')
.sort((a, b) => a[0].localeCompare(b[0]) ? -1 : 1)
.reduce((obj, [key, value]) => ({ ...obj, [key]: value }), {});

Expand Down
17 changes: 13 additions & 4 deletions src/util/getList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ module.exports = id => {
const list = { ...match };

// Load full features
list.features = featuresData.map(feature => ({
...feature,
value: list.features.includes(feature.id) ? 1 : 0,
})).sort((a, b) => {
list.features = featuresData.map(feature => {
const withValue = {
...feature,
value: list.features.includes(feature.id) ? 1 : 0,
};

delete withValue['$schema'];

return withValue;
}).sort((a, b) => {
if (a.value !== b.value) return a.value ? -1 : 1;
if (a.display !== b.display) return a.display > b.display ? -1 : 1;
return a.name.localeCompare(b.name) ? -1 : 1;
});

// Drop $schema
delete list['$schema'];

return list;
};

0 comments on commit bf4b077

Please sign in to comment.