mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-blog.git
synced 2026-10-25 21:43:53 +00:00
update overall layout
This commit is contained in:
parent
7c3bbfee42
commit
d62ac361c0
6 changed files with 123 additions and 181 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
import "@/styles/global.css";
|
import "@/styles/global.css";
|
||||||
import Remark42Counter from "@/components/Remark42Counter.astro";
|
import Remark42Counter from "@/components/Remark42Counter.astro";
|
||||||
|
import TagLink from "@/components/TagLink.astro";
|
||||||
import { getLangFromUrl } from "@/i18n";
|
import { getLangFromUrl } from "@/i18n";
|
||||||
|
|
||||||
const lang = getLangFromUrl(Astro.url);
|
const lang = getLangFromUrl(Astro.url);
|
||||||
|
|
@ -22,9 +23,7 @@ const tags = data.tags;
|
||||||
<div class="tags" transition:name={`post-tags-${data.postId}`}>
|
<div class="tags" transition:name={`post-tags-${data.postId}`}>
|
||||||
{
|
{
|
||||||
tags.map((tag: string) => (
|
tags.map((tag: string) => (
|
||||||
<p class="tag">
|
<TagLink tag={tag} lang={lang} />
|
||||||
<a href={`/${lang}/tags/${tag}`}>{tag}</a>
|
|
||||||
</p>
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -51,81 +50,31 @@ const tags = data.tags;
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<div class="section-divider"></div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tags {
|
.tags {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.4rem;
|
gap: 0.25rem 0.9rem;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.75rem;
|
||||||
margin-bottom: 0.5rem;
|
min-width: 0;
|
||||||
}
|
font-size: 0.85rem;
|
||||||
|
|
||||||
.tag {
|
|
||||||
font-family:
|
|
||||||
"Noto Sans SC",
|
|
||||||
system-ui,
|
|
||||||
-apple-system,
|
|
||||||
BlinkMacSystemFont,
|
|
||||||
"Segoe UI",
|
|
||||||
Roboto,
|
|
||||||
Oxygen,
|
|
||||||
Ubuntu,
|
|
||||||
Cantarell,
|
|
||||||
"Open Sans",
|
|
||||||
"Helvetica Neue",
|
|
||||||
sans-serif;
|
|
||||||
|
|
||||||
margin: 0;
|
|
||||||
padding: 0.22em 0.65em;
|
|
||||||
font-size: 1rem;
|
|
||||||
line-height: 1.2;
|
|
||||||
border: 1px dashed #8b6b4a;
|
|
||||||
border-radius: 0;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag a {
|
|
||||||
color: #6f4e37;
|
|
||||||
text-decoration: none;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag {
|
|
||||||
border-color: #d8c7a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag a {
|
|
||||||
color: #e6d8b8;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag {
|
|
||||||
border-color: #d8c7a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag a {
|
|
||||||
color: #e6d8b8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-card {
|
.post-card {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0 0 1rem 0;
|
margin: 0;
|
||||||
padding-left: 0;
|
padding: 0;
|
||||||
padding-bottom: 0.9rem;
|
}
|
||||||
padding-top: 0.9rem;
|
|
||||||
|
.post-card + .post-card {
|
||||||
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-link {
|
.post-link {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: stretch;
|
align-items: flex-start;
|
||||||
gap: 1rem;
|
gap: 1.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
@ -136,14 +85,13 @@ const tags = data.tags;
|
||||||
max-width: 40rem;
|
max-width: 40rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
min-height: calc(1.6em * 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-title-link {
|
.post-title-link {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-title {
|
.post-title {
|
||||||
|
|
@ -163,7 +111,8 @@ const tags = data.tags;
|
||||||
sans-serif;
|
sans-serif;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 1.34rem;
|
font-size: 1.34rem;
|
||||||
line-height: 1.6;
|
line-height: 1.5;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 3;
|
-webkit-line-clamp: 3;
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
|
|
@ -171,11 +120,13 @@ const tags = data.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-description {
|
.post-description {
|
||||||
color: black;
|
margin-top: 0.5rem;
|
||||||
|
color: #4e5e6e;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 0.92rem;
|
font-size: 0.95rem;
|
||||||
/* font-style: italic; */
|
line-height: 1.7;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-meta-row {
|
.post-meta-row {
|
||||||
|
|
@ -183,11 +134,13 @@ const tags = data.tags;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.9rem;
|
gap: 0.9rem;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #66717c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-date {
|
.post-date {
|
||||||
color: gray;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
@ -196,8 +149,6 @@ const tags = data.tags;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.7rem;
|
gap: 0.7rem;
|
||||||
color: #6f8090;
|
|
||||||
font-size: 0.92rem;
|
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
@ -208,42 +159,47 @@ const tags = data.tags;
|
||||||
gap: 0.2rem;
|
gap: 0.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-image-link {
|
||||||
|
display: block;
|
||||||
|
flex: 0 0 11rem;
|
||||||
|
width: 11rem;
|
||||||
|
aspect-ratio: 16 / 10;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.post-image {
|
.post-image {
|
||||||
width: calc((1.6em * 4) * 16 / 10);
|
width: 100%;
|
||||||
height: calc(1.6em * 4);
|
height: 100%;
|
||||||
aspect-ratio: 16 / 10;
|
aspect-ratio: 16 / 10;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: center;
|
object-position: center;
|
||||||
border: 1.5px #94a0ab dashed;
|
|
||||||
flex-shrink: 0;
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.dark) .post-description {
|
:global(.dark) .post-description {
|
||||||
color: #e6e6e6;
|
color: #c4ccd5;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.dark) .post-stats {
|
:global(.dark) .post-meta-row {
|
||||||
color: #aab7c4;
|
color: #aab7c4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.post-link {
|
.post-link {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 145px;
|
grid-template-columns: minmax(0, 1fr) clamp(88px, 24vw, 104px);
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"title title"
|
"title title"
|
||||||
"desc image"
|
"desc image"
|
||||||
"tags image"
|
"tags tags"
|
||||||
"meta image";
|
"meta meta";
|
||||||
column-gap: 0.75rem;
|
column-gap: 0.75rem;
|
||||||
row-gap: 0.2rem;
|
row-gap: 0;
|
||||||
align-items: start;
|
align-items: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-text {
|
.post-text {
|
||||||
display: contents;
|
display: contents;
|
||||||
min-height: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-title-link {
|
.post-title-link {
|
||||||
|
|
@ -258,30 +214,20 @@ const tags = data.tags;
|
||||||
grid-area: desc;
|
grid-area: desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tags {
|
||||||
|
grid-area: tags;
|
||||||
|
}
|
||||||
|
|
||||||
.post-meta-row {
|
.post-meta-row {
|
||||||
grid-area: meta;
|
grid-area: meta;
|
||||||
gap: 0.7rem;
|
gap: 0.7rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-image {
|
|
||||||
/* border: none; */
|
|
||||||
grid-area: image;
|
|
||||||
width: 100%;
|
|
||||||
height: calc(145px * 10 / 16);
|
|
||||||
align-self: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-image-link {
|
.post-image-link {
|
||||||
grid-area: image;
|
grid-area: image;
|
||||||
align-self: center;
|
margin-top: 0.5rem;
|
||||||
display: block;
|
width: 100%;
|
||||||
width: 145px;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-card {
|
|
||||||
padding-bottom: 0.2rem;
|
|
||||||
padding-top: 0.2rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -59,15 +59,15 @@ const latestPosts = filteredPosts.slice(0, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-link-wrap {
|
.more-link-wrap {
|
||||||
margin-top: 1rem;
|
margin-top: 2rem;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-link {
|
.more-link {
|
||||||
color: #6f8090;
|
color: #6f8090;
|
||||||
font-weight: 700;
|
font-weight: 400;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 1.14rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-link:hover {
|
.more-link:hover {
|
||||||
|
|
|
||||||
48
src/components/TagLink.astro
Normal file
48
src/components/TagLink.astro
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
---
|
||||||
|
interface Props {
|
||||||
|
tag: string;
|
||||||
|
lang: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { tag, lang } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<a class="tag-link" href={`/${lang}/tags/${encodeURIComponent(tag)}/`}>#{tag}</a>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.tag-link {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 100%;
|
||||||
|
padding-block: 0.2rem;
|
||||||
|
font-family: "Noto Sans SC", system-ui, sans-serif;
|
||||||
|
font-size: inherit;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #536493;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
text-decoration-line: underline;
|
||||||
|
text-decoration-style: dashed;
|
||||||
|
text-decoration-thickness: 1px;
|
||||||
|
text-underline-offset: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-link:hover,
|
||||||
|
.tag-link:focus-visible {
|
||||||
|
color: var(--text-color);
|
||||||
|
text-decoration: underline dashed 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-link:focus-visible {
|
||||||
|
outline: 2px solid currentColor;
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(html.dark) .tag-link {
|
||||||
|
color: #aabbd8;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(html.dark) .tag-link:hover,
|
||||||
|
:global(html.dark) .tag-link:focus-visible {
|
||||||
|
color: #d9e5f6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import BaseLayout from "./BaseLayout.astro";
|
import BaseLayout from "./BaseLayout.astro";
|
||||||
import Remark42Embed from "@/components/Remark42Embed.astro";
|
import Remark42Embed from "@/components/Remark42Embed.astro";
|
||||||
import PostNav from "@/components/Posts/PostNav.astro";
|
import PostNav from "@/components/Posts/PostNav.astro";
|
||||||
|
import TagLink from "@/components/TagLink.astro";
|
||||||
import PostMenu from "@/components/Posts/PostMenu.astro";
|
import PostMenu from "@/components/Posts/PostMenu.astro";
|
||||||
import Dialog from "@/components/Posts/Dialog.astro";
|
import Dialog from "@/components/Posts/Dialog.astro";
|
||||||
import { fade } from "astro:transitions";
|
import { fade } from "astro:transitions";
|
||||||
|
|
@ -61,9 +62,7 @@ const t = getTranslations(lang);
|
||||||
<div class="tags" transition:name={`post-tags-${postId}`}>
|
<div class="tags" transition:name={`post-tags-${postId}`}>
|
||||||
{
|
{
|
||||||
frontmatter.tags.map((tag: string) => (
|
frontmatter.tags.map((tag: string) => (
|
||||||
<p class="tag">
|
<TagLink tag={tag} lang={lang} />
|
||||||
<a href={`/${lang}/tags/${tag}`}>{tag}</a>
|
|
||||||
</p>
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -317,8 +316,6 @@ const t = getTranslations(lang);
|
||||||
aspect-ratio: 16 / 10;
|
aspect-ratio: 16 / 10;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: center;
|
object-position: center;
|
||||||
/* border-radius: 0.4rem; */
|
|
||||||
border: 1.5px #94a0ab dashed;
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,42 +331,13 @@ const t = getTranslations(lang);
|
||||||
.tags {
|
.tags {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.4rem;
|
gap: 0.25rem 0.9rem;
|
||||||
margin-top: 0.8rem;
|
margin-top: 0.8rem;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
|
||||||
|
|
||||||
.tag {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0.22em 0.65em;
|
|
||||||
font-size: 0.88rem;
|
font-size: 0.88rem;
|
||||||
line-height: 1.2;
|
|
||||||
border: 1px dashed #8b6b4a;
|
|
||||||
border-radius: 0;
|
|
||||||
background-color: transparent;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag a {
|
@media (max-width: 800px) {
|
||||||
color: #6f4e37;
|
|
||||||
text-decoration: none;
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag {
|
|
||||||
border-color: #d8c7a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag a {
|
|
||||||
color: #e6d8b8;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 560px) {
|
|
||||||
.post-header {
|
.post-header {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ const rssLink = lang === "zh" ? "/rss.xml" : "/en/rss.xml";
|
||||||
|
|
||||||
<div class="section-divider"></div>
|
<div class="section-divider"></div>
|
||||||
|
|
||||||
<h2>{t.home.latestTitle}</h2>
|
<h2 class="section-title">{t.home.latestTitle}</h2>
|
||||||
|
|
||||||
<PostList />
|
<PostList />
|
||||||
|
|
||||||
|
|
@ -80,4 +80,19 @@ const rssLink = lang === "zh" ? "/rss.xml" : "/en/rss.xml";
|
||||||
.page-title {
|
.page-title {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section-title,
|
||||||
|
.index :global(.latest-comments > h2) {
|
||||||
|
margin: 0 0 1.25rem;
|
||||||
|
font-family: "Noto Sans SC", system-ui, sans-serif;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #66717c;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(html.dark) .section-title,
|
||||||
|
:global(html.dark) .index :global(.latest-comments > h2) {
|
||||||
|
color: #aab7c4;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||||
|
import TagLink from "@/components/TagLink.astro";
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from "astro:content";
|
||||||
import { getTranslations, type Lang } from "@/i18n";
|
import { getTranslations, type Lang } from "@/i18n";
|
||||||
import "@/styles/global.css";
|
import "@/styles/global.css";
|
||||||
|
|
@ -24,7 +25,7 @@ const pageTitle = lang === "zh" ? "标签索引" : "Tag Index";
|
||||||
{
|
{
|
||||||
tags.map((tag) => (
|
tags.map((tag) => (
|
||||||
<p class="tag" transition:name={`post-tags-${tag}`}>
|
<p class="tag" transition:name={`post-tags-${tag}`}>
|
||||||
<a href={`/${lang}/tags/${tag}`}>{tag}</a>
|
<TagLink tag={String(tag)} lang={lang} />
|
||||||
</p>
|
</p>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
@ -40,49 +41,13 @@ const pageTitle = lang === "zh" ? "标签索引" : "Tag Index";
|
||||||
.tags {
|
.tags {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.4rem;
|
gap: 0.4rem 1.25rem;
|
||||||
margin-top: 0.8rem;
|
margin-top: 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
font-family:
|
|
||||||
"Noto Sans SC",
|
|
||||||
system-ui,
|
|
||||||
-apple-system,
|
|
||||||
BlinkMacSystemFont,
|
|
||||||
"Segoe UI",
|
|
||||||
Roboto,
|
|
||||||
Oxygen,
|
|
||||||
Ubuntu,
|
|
||||||
Cantarell,
|
|
||||||
"Open Sans",
|
|
||||||
"Helvetica Neue",
|
|
||||||
sans-serif;
|
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.22em 0.65em;
|
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
line-height: 1.2;
|
max-width: 100%;
|
||||||
border: 1px dashed #8b6b4a;
|
|
||||||
border-radius: 0;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag a {
|
|
||||||
color: #6f4e37;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag {
|
|
||||||
border-color: #d8c7a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.dark) .tag a {
|
|
||||||
color: #e6d8b8;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue