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.
|
||||
*/
|
||||
function createHTML() {
|
||||
let resultString = ''
|
||||
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'])
|
||||
.forEach(function (section) {
|
||||
if (recordsBySection.has(section)) {
|
||||
resultString += `<h1>${section}</h1>\n`
|
||||
sections.forEach(function (section) {
|
||||
resultString += `<a
|
||||
style="display: inline-block; padding: .5rem; border: 1px solid lightgray; border-radius: 2px; box-shadow: 0px 1px 2px rgba(0,0,0,0.3);"
|
||||
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 chairs = [...recordsByChair.keys()].sort()
|
||||
@ -62,7 +68,6 @@ function createHTML() {
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
fs.writeFileSync('result.txt', resultString)
|
||||
@ -93,3 +98,10 @@ function groupBy(list, keyGetter) {
|
||||
});
|
||||
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