2023-03-23 18:25:48 +08:00
|
|
|
<div xmlns:th="https://www.thymeleaf.org"
|
2024-04-28 21:06:18 +08:00
|
|
|
th:fragment="widget (sidebar)"
|
|
|
|
th:class="'card widget ' + ${sidebar.hide}"
|
2024-05-07 20:08:16 +08:00
|
|
|
th:with="categories = ${categoryFinder.list(1,1)},
|
2023-03-25 16:28:00 +08:00
|
|
|
isEmpty = ${#lists.isEmpty(categories)}">
|
|
|
|
<div class="card-title">
|
2024-05-07 20:08:16 +08:00
|
|
|
<i th:class="${#strings.defaultString(sidebar.icon, 'ri-apps-line') + ' card-title-label'}"></i><span
|
|
|
|
th:text="${#strings.defaultString(sidebar.title, '分类')}"></span>
|
2024-02-05 10:47:54 +08:00
|
|
|
<a th:if="${theme.config.sidebar.categories_more}" class="card-more" th:href="@{/categories}">更多<i
|
2023-09-12 10:44:43 +08:00
|
|
|
class="ri-arrow-right-double-line"></i></a>
|
2023-03-25 16:28:00 +08:00
|
|
|
</div>
|
|
|
|
<div th:if="${isEmpty}" class="card-empty">暂无分类</div>
|
|
|
|
<div th:unless="${isEmpty}" class="card-content">
|
2024-05-07 20:08:16 +08:00
|
|
|
<ul class="menu-list" id="categories-menu-list">
|
2023-03-25 16:28:00 +08:00
|
|
|
</ul>
|
|
|
|
</div>
|
2024-05-07 20:08:16 +08:00
|
|
|
|
|
|
|
<script th:inline="javascript">
|
|
|
|
let categories = [[${categoryFinder.listAsTree()}]]
|
|
|
|
let limitCount = [[${#strings.isEmpty(theme.config.sidebar.categories_num)? 10 : T(java.lang.Integer).parseInt(theme.config.sidebar.categories_num)}]]
|
|
|
|
let count = 0
|
|
|
|
|
|
|
|
function showCategories(categories) {
|
|
|
|
let con = ''
|
|
|
|
for (let category of categories) {
|
|
|
|
count++
|
|
|
|
if (count > limitCount) {
|
|
|
|
return con
|
|
|
|
}
|
|
|
|
con += ' <li>\n' +
|
|
|
|
' <a class="level is-marginless" href="' + category.status.permalink + '">\n' +
|
|
|
|
' <span class="level-item">'+category.spec.displayName+'</span>\n' +
|
|
|
|
' <span class="level-item tag">'+(category.status.postCount === null ? 0 : category.status.postCount)+'</span>\n' +
|
|
|
|
' </a>\n'
|
|
|
|
|
|
|
|
if (category.children.length > 0) {
|
|
|
|
con += ' <ul>\n'
|
|
|
|
con += showCategories(category.children)
|
|
|
|
con += ' </ul>\n'
|
|
|
|
}
|
|
|
|
con += ' </li> \n'
|
|
|
|
}
|
|
|
|
return con
|
|
|
|
}
|
|
|
|
$('#categories-menu-list').html(showCategories(categories));
|
|
|
|
</script>
|
2024-01-29 17:44:12 +08:00
|
|
|
</div>
|