feat: group tags by category
This commit is contained in:
parent
da73fcb440
commit
d311bbe885
2 changed files with 30 additions and 6 deletions
8
Makefile
8
Makefile
|
@ -4,7 +4,13 @@ dc-up:
|
||||||
dc-down:
|
dc-down:
|
||||||
docker compose down --volumes
|
docker compose down --volumes
|
||||||
|
|
||||||
dc-reset:
|
dc-restart:
|
||||||
make dc-down
|
make dc-down
|
||||||
make dc-up
|
make dc-up
|
||||||
|
|
||||||
|
dc-build:
|
||||||
|
docker compose build
|
||||||
|
|
||||||
|
dc-rebuild:
|
||||||
|
make dc-build
|
||||||
|
make dc-restart
|
|
@ -1,5 +1,6 @@
|
||||||
<div class='readonly-sidebar'>
|
<div class='readonly-sidebar'>
|
||||||
<h1 style='line-height: 1.2em'><%= ctx.post.title %></h1>
|
<h1 style='line-height: 1.2em'><%= ctx.post.title %></h1>
|
||||||
|
<p style='line-height: 1.2em'><%= ctx.post.description %></p>
|
||||||
<article class='details'>
|
<article class='details'>
|
||||||
<section class='download'>
|
<section class='download'>
|
||||||
<a rel='external' href='<%- ctx.post.contentUrl %>'>
|
<a rel='external' href='<%- ctx.post.contentUrl %>'>
|
||||||
|
@ -84,11 +85,28 @@
|
||||||
</nav>
|
</nav>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<nav class='tags'>
|
<%
|
||||||
<h1>Tags (<%- ctx.post.tags.length %>)</h1>
|
function kebabToTitleCase(str) {
|
||||||
<% if (ctx.post.tags.length) { %>
|
return str
|
||||||
|
.split('-') // Split the string into words using the hyphen as the delimiter
|
||||||
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize the first letter of each word
|
||||||
|
.join(' '); // Join the words back together with spaces
|
||||||
|
}
|
||||||
|
const categories = [];
|
||||||
|
|
||||||
|
for (let tag of ctx.post.tags) {
|
||||||
|
if (!categories[tag.category]) {
|
||||||
|
categories[tag.category] = []
|
||||||
|
}
|
||||||
|
categories[tag.category].push(tag)
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% for (const [category, tags] of Object.entries(categories)) { %>
|
||||||
|
<h1><%= category === "default" ? "Other Tags" : kebabToTitleCase(category) %> (<%- tags.length %>)</h1>
|
||||||
|
<% if (tags.length) { %>
|
||||||
<ul class='compact-tags'><!--
|
<ul class='compact-tags'><!--
|
||||||
--><% for (let tag of ctx.post.tags) { %><!--
|
--><% for (const tag of tags) { %><!--
|
||||||
--><li><!--
|
--><li><!--
|
||||||
--><% if (ctx.canViewTags) { %><!--
|
--><% if (ctx.canViewTags) { %><!--
|
||||||
--><a href='<%- ctx.formatClientLink('tag', tag.names[0]) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
|
--><a href='<%- ctx.formatClientLink('tag', tag.names[0]) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
|
||||||
|
@ -116,5 +134,5 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
</p>
|
</p>
|
||||||
<% } %>
|
<% } %>
|
||||||
</nav>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue