Add direct links to categories
This commit is contained in:
parent
331e4c206a
commit
3ccff54fa4
24
index.js
24
index.js
@ -33,13 +33,19 @@ function processInput (section, chair, category, audience, abbreviation,
|
|||||||
* The resulting markup is written to ./result.txt.
|
* The resulting markup is written to ./result.txt.
|
||||||
*/
|
*/
|
||||||
function createHTML() {
|
function createHTML() {
|
||||||
let resultString = ''
|
|
||||||
const recordsBySection = groupBy(records, x => x.section)
|
const recordsBySection = groupBy(records, x => x.section)
|
||||||
|
let resultString = ''
|
||||||
|
let sections = Array.from(['Informatik', 'Angewandte Informatik', 'Wirtschaftsinformatik'])
|
||||||
|
.filter(section => recordsBySection.has(section))
|
||||||
|
|
||||||
Array.from(['Informatik', 'Angewandte Informatik', 'Wirtschaftsinformatik'])
|
sections.forEach(function (section) {
|
||||||
.forEach(function (section) {
|
resultString += `<a
|
||||||
if (recordsBySection.has(section)) {
|
style="display: inline-block; padding: .5rem; border: 1px solid lightgray; border-radius: 2px; box-shadow: 0px 1px 2px rgba(0,0,0,0.3);"
|
||||||
resultString += `<h1>${section}</h1>\n`
|
href="#${convertToID(section)}">${section}</a>\n`
|
||||||
|
})
|
||||||
|
|
||||||
|
sections.forEach(function (section) {
|
||||||
|
resultString += `<h1 id="${convertToID(section)}">${section}</h1>\n`
|
||||||
|
|
||||||
let recordsByChair = groupBy(recordsBySection.get(section), x => x.chair)
|
let recordsByChair = groupBy(recordsBySection.get(section), x => x.chair)
|
||||||
let chairs = [...recordsByChair.keys()].sort()
|
let chairs = [...recordsByChair.keys()].sort()
|
||||||
@ -62,7 +68,6 @@ function createHTML() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
fs.writeFileSync('result.txt', resultString)
|
fs.writeFileSync('result.txt', resultString)
|
||||||
@ -93,3 +98,10 @@ function groupBy(list, keyGetter) {
|
|||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert to ID-compatible string by replacing non-word characters with dashes.
|
||||||
|
*/
|
||||||
|
function convertToID(string) {
|
||||||
|
return string.replace(/\W/g, '-')
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user