mirror of https://github.com/CrimsonTome/tldr.git
Correctly store language and platform mappings together (#3588)
Previously they were stored separately in their own arrays. This made them disconnected, and impossible to know if a page belonged to which platform and language combination. This PR adds an array of objects called `targets` which contains platform/language pairs.client-spec/clarity
parent
bfbe15c8e4
commit
62731a8b64
|
@ -17,3 +17,4 @@ test_result
|
||||||
# but it's been superseded by a static asset
|
# but it's been superseded by a static asset
|
||||||
# hosted at https://tldr-pages.github.io/assets/index.json
|
# hosted at https://tldr-pages.github.io/assets/index.json
|
||||||
pages/index.json
|
pages/index.json
|
||||||
|
index.json
|
||||||
|
|
|
@ -29,8 +29,19 @@ function buildPagesIndex(files) {
|
||||||
if (!index[page].language.includes(language)) {
|
if (!index[page].language.includes(language)) {
|
||||||
index[page].language.push(language);
|
index[page].language.push(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const targets = index[page].targets;
|
||||||
|
const exists = targets.some((t) => {return t.platform === os && t.language === language});
|
||||||
|
if (!exists) {
|
||||||
|
targets.push({os, language})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
index[page] = {name: page, platform: [os], language: [language]};
|
index[page] = {
|
||||||
|
name: page,
|
||||||
|
platform: [os],
|
||||||
|
language: [language],
|
||||||
|
targets: [{os, language}]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
@ -43,8 +54,9 @@ function buildPagesIndex(files) {
|
||||||
.map(function(page) {
|
.map(function(page) {
|
||||||
return {
|
return {
|
||||||
name: page,
|
name: page,
|
||||||
platform: obj[page]["platform"],
|
platform: obj[page].platform,
|
||||||
language: obj[page]["language"]
|
language: obj[page].language,
|
||||||
|
targets: obj[page].targets
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue