Filter out articles in titles when sorting

This commit is contained in:
James 2017-06-11 23:20:14 +10:00
parent 0e6d22ef6f
commit f75ff8525f

View File

@ -124,7 +124,16 @@ function processGame(game) {
model.testcase_date = recent.date;
}
let section_id = `${model.title[0]}`.toLowerCase();
const toTrim = ["the", "a", "an"];
let trimmedTitle = model.title.toLowerCase();
toTrim.forEach(trim => {
if (trimmedTitle.startsWith(trim)) {
trimmedTitle = trimmedTitle.substr(trim.length + 1);
}
});
let section_id = `${trimmedTitle[0]}`;
if (!section_id.match(/[a-z]+/)) {
section_id = "#";
}