feature(archives): Build a archives page draft

This commit is contained in:
周中平 2021-12-28 17:47:49 +08:00
parent 32abe6f33c
commit 04806b3555
No known key found for this signature in database
GPG Key ID: B1DF9DD42D8E00DC
10 changed files with 193 additions and 106 deletions

View File

@ -1,3 +0,0 @@
{
"compile-hero.disable-compile-files-on-did-save-code": false
}

View File

@ -1,48 +1,20 @@
<#include "module/macro.ftl"> <#include "module/macro.ftl">
<@layout title="归档 - ${blog_title!}"> <@layout title="归档 - ${blog_title!}">
<h1>归档</h1> <main>
<ul> <#include "module/header.ftl">
<#list archives as archive> <div class="archives">
<h2>${archive.year?c}</h2> <#list archives as archive>
<#list archive.posts as post> <div class="year">${archive.year?c}</div>
<li> <div class="list">
<a href="${post.fullPath!}">${post.title!}</a> <#list archive.posts?sort_by("createTime")?reverse as post>
</li> <div class="title">
<a href="${post.fullPath!}">${post.title!}</a>
<div class="time"><span class="date">${post.createTime?string('MM-dd')}</span></div>
</div>
</#list>
</div>
</#list> </#list>
</#list> </div>
</ul> <#include "module/pagination.ftl">
</main>
<h1>分页</h1>
<#if posts.totalPages gt 1>
<ul>
<@paginationTag method="archives" page="${posts.number}" total="${posts.totalPages}" display="3">
<#if pagination.hasPrev>
<li>
<a href="${pagination.prevPageFullPath!}">
上一页
</a>
</li>
</#if>
<#list pagination.rainbowPages as number>
<li>
<#if number.isCurrent>
<span class="current">第 ${number.page!} 页</span>
<#else>
<a href="${number.fullPath!}">第 ${number.page!} 页</a>
</#if>
</li>
</#list>
<#if pagination.hasNext>
<li>
<a href="${pagination.nextPageFullPath!}">
下一页
</a>
</li>
</#if>
</@paginationTag>
</ul>
<#else>
<span>当前只有一页</span>
</#if>
</@layout> </@layout>

View File

@ -1,30 +1,7 @@
<#include "module/macro.ftl"> <#include "module/macro.ftl">
<@layout title="${blog_title!}"> <@layout title="${blog_title!}">
<main> <main>
<div class="header"> <#include "module/header.ftl">
<div class="title">
<a href="${blog_url!}"><span>无尽光芒</span></a>
</div>
<div class="description">
<p>${settings.sub_title!'the site subtitle'}</p>
<div class="socials">
<#if settings.github??>
<a href="${settings.github}" title="github" target="_blank"><i class="ri-github-line"></i></a>
</#if>
<#if settings.wechat??>
<a href="${settings.wechat}" title="wechat" target="_blank"><i class="ri-wechat-line"></i></a>
</#if>
<#if settings.bilibili??>
<a href="${settings.bilibili}" title="bilibili" target="_blank"><i class="ri-bilibili-line"></i></a>
</#if>
<#if settings.mail??>
<a href="mailto:${settings.mail}" title="mail" target="_blank"><i class="ri-mail-line"></i></a>
</#if>
<a href="/rss.xml" type="application/rss+xml" title="rss" target="_blank"><i class="ri-rss-line"></i></a>
</div>
</div>
</div>
<#list posts.content as post> <#list posts.content as post>
<div class="post"> <div class="post">
<h1><a href='${post.fullPath!}'>${post.title!}</a></h1> <h1><a href='${post.fullPath!}'>${post.title!}</a></h1>
@ -48,21 +25,6 @@
</div> </div>
</#list> </#list>
<div class="pagenav"> <#include "module/pagination.ftl">
<#if posts.totalPages gt 1>
<@paginationTag method="index" page="${posts.number}" total="${posts.totalPages}" display="3">
<#if pagination.hasPrev>
<a href="${pagination.prevPageFullPath!}" class="pre">
返回上页
</a>
</#if>
<#if pagination.hasNext>
<a href="${pagination.nextPageFullPath!}" class="next">
更多文章
</a>
</#if>
</@paginationTag>
</#if>
</div>
</main> </main>
</@layout> </@layout>

23
module/header.ftl Normal file
View File

@ -0,0 +1,23 @@
<div class="header">
<div class="title">
<a href="${blog_url!}"><span>无尽光芒</span></a>
</div>
<div class="description">
<p>${settings.sub_title!'the site subtitle'}</p>
<div class="socials">
<#if settings.github??>
<a href="${settings.github}" title="github" target="_blank"><i class="ri-github-line"></i></a>
</#if>
<#if settings.wechat??>
<a href="${settings.wechat}" title="wechat" target="_blank"><i class="ri-wechat-line"></i></a>
</#if>
<#if settings.bilibili??>
<a href="${settings.bilibili}" title="bilibili" target="_blank"><i class="ri-bilibili-line"></i></a>
</#if>
<#if settings.mail??>
<a href="mailto:${settings.mail}" title="mail" target="_blank"><i class="ri-mail-line"></i></a>
</#if>
<a href="/rss.xml" type="application/rss+xml" title="rss" target="_blank"><i class="ri-rss-line"></i></a>
</div>
</div>
</div>

View File

@ -16,7 +16,7 @@
<link rel="stylesheet" href="${theme_base!}/source/css/redemption.css"/> <link rel="stylesheet" href="${theme_base!}/source/css/redemption.css"/>
</head> </head>
<body class="animate__animated animate__fadeInDown"> <body class="animate__animated animate__fadeInDown">
<#-- <#include "menu.ftl"> --> <#include "menu.ftl">
<#-- 主体 --> <#-- 主体 -->
<#nested > <#nested >

16
module/pagination.ftl Normal file
View File

@ -0,0 +1,16 @@
<#if posts.totalPages gt 1>
<@paginationTag method="index" page="${posts.number}" total="${posts.totalPages}" display="3">
<div class="pagenav">
<#if pagination.hasPrev>
<a href="${pagination.prevPageFullPath!}" class="pre">
返回上页
</a>
</#if>
<#if pagination.hasNext>
<a href="${pagination.nextPageFullPath!}" class="next">
更多文章
</a>
</#if>
</div>
</@paginationTag>
</#if>

View File

@ -65,35 +65,35 @@ main .post {
width: 45rem; width: 45rem;
padding-top: 1rem; padding-top: 1rem;
} }
main .post h1 a { main .post > h1 a {
letter-spacing: 0.0625rem; letter-spacing: 0.0625rem;
font-size: 1.375rem; font-size: 1.375rem;
line-height: 1.75rem; line-height: 1.75rem;
} }
main .post p { main .post > p {
line-height: 1.5rem; line-height: 1.5rem;
text-indent: 2rem; text-indent: 2rem;
} }
main .post .info { main .post > .info {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
padding: 0.5rem 0 2rem 0; padding: 0.5rem 0 2rem 0;
} }
main .post .info span { main .post > .info span {
font-weight: 400; font-weight: 400;
font-size: 0.75rem; font-size: 0.75rem;
} }
main .post .info a { main .post > .info a {
font-size: 0.75rem; font-size: 0.75rem;
} }
main .post .info .date, main .post > .info .date,
main .post .info .tag { main .post > .info .tag {
margin: 0 0.5rem; margin: 0 0.5rem;
} }
main .post .info .date i, main .post > .info .date i,
main .post .info .tag i { main .post > .info .tag i {
position: relative; position: relative;
top: 0.05rem; top: 0.05rem;
} }
@ -102,10 +102,46 @@ main .pagenav {
justify-content: space-between; justify-content: space-between;
padding: 2rem 0 5rem 0; padding: 2rem 0 5rem 0;
} }
main .pagenav a { main .pagenav > a {
text-decoration: none; text-decoration: none;
margin: 0 2rem; margin: 0 2rem;
} }
main .archives {
width: 45rem;
padding-top: 1rem;
font-size: 0.875rem;
}
main .archives > li {
list-style-type: none;
padding: 0;
}
main .archives > .year {
font-size: 1.4rem;
font-weight: 600;
line-height: 2.2rem;
letter-spacing: 0.1rem;
padding: 0.625rem 0;
}
main .archives > .list {
margin-bottom: 3rem;
line-height: 1.75rem;
}
main .archives > .list .title {
padding-bottom: 0.3rem;
}
main .archives > .list .title a {
display: inline-block;
width: 85%;
color: #1f1f1f;
}
main .archives > .list .title .time {
float: right;
color: #c5c5c5;
font-size: 0.875rem;
}
main .archives > .list .title a:hover {
color: #1f1f1f;
}
footer { footer {
padding: 2rem 0; padding: 2rem 0;

View File

@ -1,14 +1,16 @@
@charset "UTF-8"; @charset "UTF-8";
// 全局 HTML 配置 // 全局 HTML 配置
html { html {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji'; 'Noto Color Emoji';
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
// 滚动条 // 滚动条
html::-webkit-scrollbar { html::-webkit-scrollbar {
width: 10px; width: 10px;
@ -76,10 +78,11 @@ main {
width: 50rem; width: 50rem;
margin-top: 4rem; margin-top: 4rem;
.post { .post{
width: 45rem; width: 45rem;
padding-top: 1rem; padding-top: 1rem;
}
.post > {
h1 { h1 {
a { a {
letter-spacing: 0.0625rem; letter-spacing: 0.0625rem;
@ -126,18 +129,67 @@ main {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 2rem 0 5rem 0; padding: 2rem 0 5rem 0;
}
.pagenav > {
a { a {
text-decoration: none; text-decoration: none;
margin: 0 2rem; margin: 0 2rem;
} }
} }
.archives{
width: 45rem;
padding-top: 1rem;
font-size: 0.875rem;
}
.archives > {
li {
list-style-type: none;
padding: 0;
}
.year {
font-size: 1.4rem;
font-weight: 600;
line-height: 2.2rem;
letter-spacing: 0.1rem;
padding: 0.625rem 0;
}
.list {
margin-bottom: 3rem;
line-height: 1.75rem;
.title{
padding-bottom: 0.3rem;
a {
display: inline-block;
width: 85%;
color: #1f1f1f;
}
.time {
float: right;
color: #c5c5c5;
font-size: 0.875rem;
}
a:hover {
color: #1f1f1f;
}
}
}
}
} }
footer { footer {
padding: 2rem 0; padding: 2rem 0;
.copyright { .copyright {
font-size: 0.8rem; font-size: 0.8rem;
a { a {
margin: 0 0.125rem; margin: 0 0.125rem;

View File

@ -70,6 +70,15 @@ main .pagenav a {
main .pagenav a:hover { main .pagenav a:hover {
color: rgba(0, 0, 0, 0.65); color: rgba(0, 0, 0, 0.65);
} }
main .archives > .list .title a {
color: black;
}
main .archives > .list .title a:hover {
color: rgba(0, 0, 0, 0.65);
}
main .archives > .list .title .time {
color: #c5c5c5;
}
footer .copyright a { footer .copyright a {
color: rgba(0, 0, 0, 0.25); color: rgba(0, 0, 0, 0.25);

View File

@ -63,7 +63,7 @@ body {
main { main {
background: #ffffff; background: #ffffff;
box-shadow: 0 0.375rem 1rem -0.5rem rgba(0, 0, 0, 0.08); box-shadow: 0 0.375rem 1rem -0.5rem rgba(0, 0, 0, 0.08);
// 首页
.post { .post {
h1 { h1 {
a { a {
@ -96,7 +96,7 @@ main {
} }
} }
} }
// 文章分页
.pagenav { .pagenav {
border-bottom: 1px solid #f2f2f2; border-bottom: 1px solid #f2f2f2;
@ -108,6 +108,24 @@ main {
} }
} }
} }
// 归档页面
.archives > {
.list {
.title{
a {
color: rgb(0, 0, 0);
&:hover {
color: rgb(0, 0, 0, 0.65);
}
}
.time {
color: #c5c5c5;
}
}
}
}
} }
// 脚注 // 脚注
@ -122,4 +140,6 @@ footer {
} }
} }
} }
//