diff --git a/public/js/showcase.js b/public/js/showcase.js index d2a2e9e9..1f39ab09 100644 --- a/public/js/showcase.js +++ b/public/js/showcase.js @@ -7,6 +7,7 @@ const TimelineMediaTypes = { const showcaseItemTemplate = makeTemplateCloner("showcase_item"); const modalTemplate = makeTemplateCloner("timeline_modal"); +const tagTemplate = makeTemplateCloner("timeline_item_tag"); function showcaseTimestamp(rawDate) { const date = new Date(rawDate*1000); @@ -95,6 +96,17 @@ function makeShowcaseItem(timelineItem) { modalEl.date.textContent = timestamp; modalEl.date.setAttribute("href", timelineItem.snippet_url); + if (timelineItem.tags.length === 0) { + modalEl.tags.remove(); + } else { + for (const tag of timelineItem.tags) { + const tagItem = tagTemplate(); + tagItem.tag.innerText = tag.text; + + modalEl.tags.appendChild(tagItem.root); + } + } + modalEl.discord_link.href = timelineItem.discord_message_url; function close() { diff --git a/src/templates/mapping.go b/src/templates/mapping.go index 30cd2db7..0c402a04 100644 --- a/src/templates/mapping.go +++ b/src/templates/mapping.go @@ -307,7 +307,23 @@ func TimelineItemsToJSON(items []TimelineItem) string { builder.WriteString(`"discord_message_url":"`) builder.WriteString(item.DiscordMessageUrl) - builder.WriteString(`"`) + builder.WriteString(`",`) + + builder.WriteString(`"tags":[`) + for _, tag := range item.Tags { + builder.WriteString(`{`) + + builder.WriteString(`"text":"`) + builder.WriteString(tag.Text) + builder.WriteString(`",`) + + builder.WriteString(`"url":"`) + builder.WriteString(tag.Url) + builder.WriteString(`"`) + + builder.WriteString(`}`) + } + builder.WriteString(`]`) builder.WriteRune('}') } diff --git a/src/templates/src/include/showcase_templates.html b/src/templates/src/include/showcase_templates.html index 3affda67..c640a927 100644 --- a/src/templates/src/include/showcase_templates.html +++ b/src/templates/src/include/showcase_templates.html @@ -30,6 +30,7 @@