Skip to content

Commit

Permalink
🎉 Add category -> 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EveSunMaple committed Aug 1, 2024
1 parent 81a6855 commit 4cbaa88
Show file tree
Hide file tree
Showing 32 changed files with 762 additions and 217 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,22 @@

- 单页页面改成了十篇文章
- 去掉了 layout 的 title

## [2.5.0] - 2024-8-2

### Features

- 添加分类功能,现在你可以为你的文章添加两个独立的索引:分类与标签
- 给分类与标签的文章列表页面添加了分页功能,不再是一整页了
- 在侧边栏集成了分类的功能,来自 issue #10

### Refactored

- 现在如果文章没有图片,它的文章信息将会填充
- 修改了分页按钮的样式
- 微调样式,来自 issue #9

### Fix

- 修复在文章过多时分页失效的问题
- 修复在 issue #11 中提到的问题
4 changes: 2 additions & 2 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frosti-test",
"type": "module",
"version": "2.5.0-rc",
"version": "2.5.0",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand All @@ -16,7 +16,7 @@
"@astrojs/sitemap": "^3.1.6",
"@astrojs/tailwind": "^5.1.0",
"@playform/compress": "^0.0.13",
"astro": "^4.12.3",
"astro": "^4.13.0",
"astro-icon": "^1.1.0",
"astro-pagefind": "^1.6.0",
"dayjs": "^1.11.12",
Expand All @@ -27,7 +27,7 @@
"rehype-katex": "^7.0.0",
"remark-math": "^6.0.0",
"sass": "^1.77.8",
"shiki": "^1.12.0",
"shiki": "^1.12.1",
"twikoo": "^1.6.38",
"typescript": "^5.5.4"
},
Expand Down
236 changes: 118 additions & 118 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions src/components/BaseCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const {
image,
pubDate,
badge,
categories,
tags,
isBlog = false,
url = decodeURIComponent(Astro.url.toString()),
} = Astro.props as CardInfo;
const displayDate = dayjs(pubDate).format(DATE_FORMAT);
const hasTategories = categories && categories.length > 0;
const hasTags = tags && tags.length > 0;
---

Expand Down Expand Up @@ -42,12 +44,30 @@ const hasTags = tags && tags.length > 0;
isBlog && (
<>
<h1 id="h1">{title}</h1>
<div class="info mt-5">
<div class="info mt-2">
{displayDate && (
<div class="badge badge-neutral mr-2">{displayDate}</div>
<div class="badge badge-neutral">{displayDate}</div>
)}
<span>&thinsp;</span>
{hasTategories ? (
categories.map((categoroy) => (
<>
<a
href={`/blog/categories/${categoroy}`}
class="btn btn-xs btn-accent rounded-full"
>
{categoroy}
</a>
<span>&thinsp;</span>
</>
))
) : (
<div class="btn btn-xs btn-secondary btn-disabled rounded-full">
{infoTest.noCategory}
</div>
)}
{badge && <div class="badge badge-primary">{badge}</div>}
<div class="tags mt-4">
<div class="tags mt-2">
<code>{infoTest.tag}</code>
{hasTags ? (
tags.map((tag) => (
Expand Down
48 changes: 31 additions & 17 deletions src/components/EnvelopeCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import dayjs from "dayjs";
import { Image } from "astro:assets";
import { infoTest } from "../consts";
import type { EnvelopeInfo } from "../types";
const { title, desc, image, pubDate, badge, tags, url } =
const { title, desc, image, pubDate, badge, categories, tags, url } =
Astro.props as EnvelopeInfo;
const tag_url = url.split("/").slice(0, -1).join("/") + "/tag";
const displayDate = dayjs(pubDate).format("ddd MMM DD YYYY");
const hasTategories = categories && categories.length > 0;
const hasTags = tags && tags.length > 0;
const target = "_self";
---
Expand All @@ -19,24 +19,40 @@ const target = "_self";
>
<div class="relative w-full h-full p-6 flex flex-col justify-between">
<a href={url} target={target}>
<h1 id={title}>
<h1 id={title} class="p-2">
{title}
</h1>
</a>
<div class="m-2">{desc}</div>
<div class="m-2">
{displayDate && <div class="badge badge-neutral">{displayDate}</div>}
<span>&thinsp;</span>{
hasTategories ? (
categories.map((categoroy) => (
<>
<a
href={`/blog/categories/${categoroy}`}
class="btn btn-xs btn-accent rounded-full"
>
{categoroy}
</a>
<span>&thinsp;</span>
</>
))
) : (
<div class="btn btn-xs btn-secondary btn-disabled rounded-full">
{infoTest.noCategory}
</div>
)
}
{badge && <div class="badge badge-primary">{badge}</div>}
<div class="tags">
<div class="tags mt-2">
<code>{infoTest.tag}</code>
{
hasTags ? (
tags.map((tag) => (
<>
<a
href={`${tag_url}/${tag}`}
class="btn btn-xs btn-secondary"
>
<a href={`/blog/tag/${tag}`} class="btn btn-xs btn-secondary">
{tag}
</a>
<span>&thinsp;</span>
Expand All @@ -53,21 +69,19 @@ const target = "_self";
</div>
</div>

<div
class="relative w-full lg:w-2/5 h-auto rounded-none overflow-hidden lg:order-2 order-1"
>
{
image && (
{
image && (
<div class="relative w-full lg:w-2/5 h-auto rounded-none overflow-hidden lg:order-2 order-1">
<Image
src={image}
alt={title}
width="300"
height="200"
format="webp"
loading="lazy"
loading="eager"
class="object-cover w-full h-full"
/>
)
}
</div>
</div>
)
}
</div>
2 changes: 1 addition & 1 deletion src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { SITE_TITLE } from "../consts";
</div>
<div class="navbar-end">
<div class="flex justify-center card bg-base-100 w-12 h-12">
<label for="themeToggle2" class="" id="themeLabel2"
<label for="themeToggle2" id="themeLabel2" class="hidden"
><span class="sr-only">Theme Toggle</span>
<input type="checkbox" id="themeToggle2" />
<svg
Expand Down
3 changes: 2 additions & 1 deletion src/components/HeaderMenu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { menuItems } from "../consts.ts";
---

<ul
tabindex="0"
class="menu menu-sm dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow-xl"
>
{
Expand All @@ -12,8 +11,10 @@ import { menuItems } from "../consts.ts";
<a
class="menu-item text-xl font-bold p-4"
id={`header-${item.id}`}
title={item.id}
href={item.href}
target={item.target || "_self"}
aria-label={item.text}
>
{item.text}
</a>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ProfileCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { USER_AVATAR } from "../consts";
width={300}
height={300}
src={USER_AVATAR}
alt="Profile image"
alt="Profile"
loading="eager"
/>
</div>
<Menu />
Expand Down
55 changes: 42 additions & 13 deletions src/components/ProfileCardMenu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,48 @@ import { Icon } from "astro-icon/components";
>
{
menuItems.map((item) => (
<li class="w-full">
<a
class="flex justify-center lg:justify-start items-center text-center text-xl md:text-3xl lg:text-xl font-bold p-4"
id={item.id}
title={item.id}
href={item.href}
target={item.target || "_self"}
>
<span class="inline-flex justify-center">
<Icon name={`menu/${item.svg}`} />
</span>
<span class="hidden lg:inline ml-2">{item.text}</span>
</a>
<li class="w-full relative">
{item.subItems ? (
<details class="menu-item">
<summary class="justify-center lg:justify-start items-center text-center text-xl md:text-3xl lg:text-xl font-bold p-4">
<span class="justify-center">
<Icon name={`menu/${item.svg}`} />
</span>
<span class="hidden lg:inline ml-2">{item.text}</span>
</summary>
<ul>
{item.subItems.map((subItem) => (
<li>
<a
class="menu-item text-xl font-bold p-4"
id={`header-${subItem.id}`}
href={subItem.href}
target={subItem.target || "_self"}
aria-label={subItem.text}
>
<span class="inline-flex justify-center">
<Icon name={`menu/${subItem.svg}`} />
</span>
<span class="hidden lg:inline ml-2">{subItem.text}</span>
</a>
</li>
))}
</ul>
</details>
) : (
<a
class="flex justify-center lg:justify-start items-center text-center text-xl md:text-3xl lg:text-xl font-bold p-4"
id={item.id}
title={item.id}
href={item.href}
target={item.target || "_self"}
>
<span class="inline-flex justify-center">
<Icon name={`menu/${item.svg}`} />
</span>
<span class="hidden lg:inline ml-2">{item.text}</span>
</a>
)}
</li>
))
}
Expand Down
18 changes: 8 additions & 10 deletions src/components/ProjectCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { title, image, desc, url, target = "_blank" } = Astro.props;
class="envelope-back relative w-full h-full p-6 flex flex-col justify-between"
>
<a class="envelope-title" href={url} target={target}>
<h1 id={title}>{title}</h1>
<h1 id={title} class="p-2">{title}</h1>
</a>
<div class="m-2">{desc}</div>
<div class="m-2 flex">
Expand Down Expand Up @@ -103,21 +103,19 @@ const { title, image, desc, url, target = "_blank" } = Astro.props;
</div>
</div>
</div>
<div
class="relative w-full lg:w-2/5 h-auto rounded-none overflow-hidden lg:order-2 order-1"
>
{
image && (
{
image && (
<div class="relative w-full lg:w-2/5 h-auto rounded-none overflow-hidden lg:order-2 order-1">
<Image
src={image}
alt={title}
width="300"
height="200"
format="webp"
loading="lazy"
loading="eager"
class="object-cover w-full h-full"
/>
)
}
</div>
</div>
)
}
</div>
4 changes: 3 additions & 1 deletion src/components/ThemeIcon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class="flex justify-center card bg-base-100 btn btn-ghost w-auto h-10"
id="themeToggle"
>
<label for="themeToggle1" id="themeLabel1"
<label for="themeToggle1" id="themeLabel1" class="hidden"
><span class="sr-only">Theme Toggle</span>
<input type="checkbox" id="themeToggle1" />
<svg
Expand Down Expand Up @@ -100,10 +100,12 @@

// Add classes if elements are not null
if (themeLabel1) {
themeLabel1.classList.remove("hidden");
themeLabel1.classList.add("swap");
themeLabel1.classList.add("swap-rotate");
}
if (themeLabel2) {
themeLabel2.classList.remove("hidden");
themeLabel2.classList.add("swap");
themeLabel2.classList.add("swap-rotate");
}
Expand Down
1 change: 1 addition & 0 deletions src/components/page/LinkCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Image } from "astro:assets";
height={100}
format="webp"
alt={title}
loading="eager"
class="max-w-full md:max-w-[13rem] rounded-lg"
/>
)
Expand Down
Loading

0 comments on commit 4cbaa88

Please sign in to comment.