Use multipĺe tags

This commit is contained in:
Augusto Gunsch 2021-12-26 13:11:21 -03:00
parent 995f49ae14
commit 8c191041a8
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 13 additions and 5 deletions

View File

@ -117,9 +117,17 @@ function generateHtml(word, data) {
data.forEach(entry => {
html += `<h1>${entry.word} <span class="pos">(${entry.pos})</span></h1>`
if('senses' in entry) {
if('tags' in entry.senses[0]) {
html += '<div class="tags">'
html += entry.senses[0].tags.map(tag => `<mark>${tag}</mark>`).join(', ');
let tags = [];
entry.senses.forEach(sense => {
if('tags' in sense) {
tags.push(...sense.tags);
}
});
if(tags.length > 0) {
tags = [...new Set(tags)];
html += '<div class="tags">Tags: '
html += tags.map(tag => `<mark>${tag}</mark>`).join(', ')
html += '</div>'
}