Skip to content

Commit

Permalink
pref: 优化归档页面并默认展示所有文章 (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
LIlGG authored May 30, 2024
1 parent 2f712af commit e4e986f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/css/theme/archives/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
&::before {
content: "";
position: absolute;
height: 75%;
height: calc(100% - 65px);
border-left: 1px dashed #fff;
left: 17px;
top: 30px;
Expand Down
13 changes: 13 additions & 0 deletions src/page/archives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { documentFunction } from "../main";
//TODO 尝试使用 animate 来重构动画,去掉 jquery 某些过渡动画比较不方便。

export default class Archives {

@documentFunction()
public initArchiveHeight() {
const archiveActiveElements = document.querySelectorAll(".archive-item.active");
archiveActiveElements.forEach((element) => {
const posts = element.querySelector(".archive-posts") as HTMLElement;
var height = posts?.scrollHeight;
posts.style.maxHeight = height + 'px';
});
}

@documentFunction()
public registerArchiveEvent() {
const archiveTitleElements = document.querySelectorAll(".archives-article .archive-title h3");
Expand All @@ -11,6 +22,8 @@ export default class Archives {
const archiveElement = element.parentElement?.parentElement;
const posts = archiveElement?.querySelector(".archive-posts") as HTMLElement;
if (archiveElement?.classList.contains("active")) {
var height = posts?.scrollHeight;
posts.style.maxHeight = height + 'px';
posts.style.maxHeight = '0';
archiveElement.classList.remove("active");
} else {
Expand Down
2 changes: 1 addition & 1 deletion templates/archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1 data-i18n="page.archives.title"></h1>
<article class="archives-article">
<div id="archives-temp" class="archives-inner">
<div class="archives-content">
<th:block th:each="archive, archiveStat : ${archives.items}">
<th:block th:each="archive, archiveStat : ${postFinder.archives(1, 0).items}">
<th:block th:each="month, monthStat : ${archive.months}">
<div class="archive-item" th:classappend="${archiveStat.index == 0 ? 'active' : ''}" th:id="|arti-${archive.year}-${month.month}|">
<div class="archive-title">
Expand Down
2 changes: 1 addition & 1 deletion templates/assets/dist/css/main.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/assets/dist/page/archives.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4e986f

Please sign in to comment.