Skip to content

Commit

Permalink
🎉 Pin your article -> 2.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
EveSunMaple committed Aug 18, 2024
1 parent bc6c8a3 commit 25ff1bd
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 31 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,15 @@
### Fix

- 修复了搜索组件无法正常加载的问题

## [2.5.5] - 2024-8-18

### Features

- 添加了置顶功能,现在你可以给文章 badge 属性 设置为 `Pin` 来置顶你的文章

### Refactored

- 清理了项目代码
- 修改了侧边卡片的样式
- 修改了原 DaisyUI 内建的逻辑,改成点击按钮收回而不是点击外部收回
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "frosti",
"type": "module",
"version": "2.5.4-hotfix.1",
"version": "2.5.5",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand Down
40 changes: 21 additions & 19 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@ import { SITE_TITLE } from "../consts";
class="navbar max-md:translate-y-0 fixed px-2 w-full transform -translate-y-full text-center z-50 transition-transform bg-base-100 shadow-xl"
>
<div class="navbar-start">
<div class="dropdown">
<div
tabindex="0"
role="button"
class="btn btn-ghost"
id="content"
title="Content"
>
<svg
class="swap-off fill-current"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 512 512"
><path
d="M64,384H448V341.33H64Zm0-106.67H448V234.67H64ZM64,128v42.67H448V128Z"
></path></svg
<details>
<summary>
<div
tabindex="0"
role="button"
class="btn btn-ghost"
id="navbar"
title="Navbar"
>
</div>
<svg
class="swap-off fill-current"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 512 512"
><path
d="M64,384H448V341.33H64Zm0-106.67H448V234.67H64ZM64,128v42.67H448V128Z"
></path>
</svg>
</div>
</summary>
<Menu />
</div>
</details>
</div>
<div class="navbar-center">
<a class="btn btn-ghost text-xl" href="/">{SITE_TITLE}</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderMenu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { menuItems } from "../consts.ts";
---

<ul
class="menu menu-sm dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow-xl"
class="menu menu-sm fixed bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow-xl lg:hidden"
>
{
menuItems.map((item) => (
Expand Down
6 changes: 3 additions & 3 deletions src/components/blog/collapse.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
const { title } = Astro.props;
---

<div
<details
tabindex="0"
class="collapse collapse-arrow border-base-300 bg-base-200 border"
>
<div class="collapse-title text-xl font-medium">{title}</div>
<summary class="collapse-title text-xl font-medium">{title}</summary>
<div class="collapse-content"><slot /></div>
</div>
</details>
2 changes: 1 addition & 1 deletion src/content/blog/markdown-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ categories:
- tech
tags:
- Makrdown
badge: Guide
badge: Pin
---

Here is a sample of some basic Markdown syntax that can be used when writing Markdown content in Astro.
Expand Down
17 changes: 13 additions & 4 deletions src/pages/blog/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ import { infoTest } from "../../consts";
export async function getStaticPaths({ paginate }: { paginate: any }) {
const posts = await getCollection("blog");
posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
return paginate(posts, { pageSize: 8 });
const topPosts = posts.filter((post) => post.data.badge === "Pin");
const otherPosts = posts.filter((post) => post.data.badge !== "Pin");
topPosts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
otherPosts.sort(
(a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()
);
const sortedPosts = [...topPosts, ...otherPosts];
return paginate(sortedPosts, { pageSize: 8 });
}
const { page }: { page: Page } = Astro.props;
Expand Down Expand Up @@ -73,7 +82,7 @@ const pageLinks = generatePageLinks(totalPages);
href={page.url.prev ? page.url.prev : `javascript:`}
class={page.url.prev
? `btn bg-base-100 shadow-xl`
: `btn btn-disabled bg-base-100 shadow-xl`}
: `btn btn-disabled bg-base-100 shadow-xl`}
>
<svg
class="h-6 w-6 fill-current md:h-8 md:w-8"
Expand Down Expand Up @@ -146,7 +155,7 @@ const pageLinks = generatePageLinks(totalPages);
href={page.url.next ? page.url.next : `javascript:`}
class={page.url.next
? `btn bg-base-100 shadow-xl`
: `btn btn-disabled bg-base-100 shadow-xl`}
: `btn btn-disabled bg-base-100 shadow-xl`}
>
<span class="hidden lg:inline ml-2">{infoTest.nextPage}</span>
<svg
Expand Down
4 changes: 4 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ body {
background-size: 100% 600px;
}

summary {
list-style: none;
}

@media (max-width: 720px) {
body {
@apply text-lg;
Expand Down

0 comments on commit 25ff1bd

Please sign in to comment.