Skip to content

Commit 68fec3e

Browse files
committed
feat: add function
1 parent a997f93 commit 68fec3e

File tree

5 files changed

+133
-120
lines changed

5 files changed

+133
-120
lines changed

src/pages/products.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
import MainGridLayout from "../layouts/MainGridLayout.astro";
2+
import MainGridLayout from '../layouts/MainGridLayout.astro'
33
4-
import { getEntry } from "astro:content";
5-
import Markdown from "@components/misc/Markdown.astro";
4+
import { getEntry } from 'astro:content'
5+
import Markdown from '@components/misc/Markdown.astro'
66
7-
const productsPost = await getEntry("spec", "products");
7+
const productsPost = await getEntry('spec', 'products')
88
9-
const { Content } = await productsPost.render();
9+
const { Content } = await productsPost.render()
1010
---
1111

1212
<MainGridLayout title="作品" description="作品">

src/styles/markdown.css

Lines changed: 75 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,98 @@
11
.custom-md {
2-
h1 {
3-
@apply text-3xl;
2+
h1 {
3+
@apply text-3xl;
4+
}
5+
6+
h1,
7+
h2,
8+
h3,
9+
h4,
10+
h5,
11+
h6 {
12+
.anchor {
13+
@apply transition -m-0.5 ml-[0.2ch] p-0.5 select-none opacity-0 no-underline !important;
14+
15+
.anchor-icon {
16+
@apply mx-[0.45ch] !important;
17+
}
418
}
519

6-
h1, h2, h3, h4, h5, h6 {
7-
.anchor {
8-
@apply transition -m-0.5 ml-[0.2ch] p-0.5 select-none opacity-0 no-underline !important;
9-
10-
.anchor-icon {
11-
@apply mx-[0.45ch] !important;
12-
}
13-
}
14-
15-
&:hover {
16-
.anchor {
17-
@apply opacity-100 !important;
18-
}
19-
}
20+
&:hover {
21+
.anchor {
22+
@apply opacity-100 !important;
23+
}
2024
}
25+
}
2126

22-
a:not(.no-styling) {
23-
@apply relative bg-none link font-medium text-[var(--primary)]
27+
a:not(.no-styling) {
28+
@apply relative bg-none link font-medium text-[var(--primary)]
2429
underline decoration-[var(--link-underline)] decoration-1 decoration-dashed underline-offset-4;
2530

26-
&:hover, &:active {
27-
@apply decoration-transparent;
28-
}
31+
&:hover,
32+
&:active {
33+
@apply decoration-transparent;
2934
}
35+
}
3036

31-
code {
32-
@apply bg-[var(--inline-code-bg)] text-[var(--inline-code-color)] px-1 py-0.5 rounded-md overflow-hidden;
37+
code {
38+
@apply bg-[var(--inline-code-bg)] text-[var(--inline-code-color)] px-1 py-0.5 rounded-md overflow-hidden;
3339

34-
font-family: 'JetBrains Mono Variable', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
35-
&:before {
36-
content:none;
37-
}
38-
&:after {
39-
content:none;
40-
}
40+
font-family: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo,
41+
Monaco, Consolas, Liberation Mono, Courier New, monospace;
42+
&:before {
43+
content: none;
44+
}
45+
&:after {
46+
content: none;
47+
}
4148

42-
counter-reset: line;
43-
span.line {
44-
&:before {
45-
@apply text-white/25 mr-4 w-4 inline-block;
46-
content: counter(line);
47-
counter-increment: line;
48-
direction: rtl;
49-
}
50-
&:last-child:empty, &:last-child:has(> span:empty:only-child) {
51-
display: none;
52-
}
53-
}
49+
counter-reset: line;
50+
span.line {
51+
&:before {
52+
@apply text-white/25 mr-4 w-4 inline-block;
53+
content: counter(line);
54+
counter-increment: line;
55+
direction: rtl;
56+
}
57+
&:last-child:empty,
58+
&:last-child:has(> span:empty:only-child) {
59+
display: none;
60+
}
5461
}
62+
}
5563

56-
pre {
57-
@apply bg-[var(--codeblock-bg)] !important;
58-
@apply rounded-xl px-5;
64+
pre {
65+
@apply bg-[var(--codeblock-bg)] !important;
66+
@apply rounded-xl px-5;
5967

60-
code {
61-
@apply bg-transparent text-inherit text-sm p-0;
68+
code {
69+
@apply bg-transparent text-inherit text-sm p-0;
6270

63-
::selection {
64-
@apply bg-[var(--codeblock-selection)];
65-
}
66-
}
71+
::selection {
72+
@apply bg-[var(--codeblock-selection)];
73+
}
6774
}
75+
}
6876

69-
ul, ol {
70-
li::marker {
71-
@apply text-[var(--primary)];
72-
}
77+
ul,
78+
ol {
79+
li::marker {
80+
@apply text-[var(--primary)];
7381
}
82+
}
7483

75-
blockquote {
76-
@apply not-italic border-transparent relative;
77-
font-weight: inherit;
84+
blockquote {
85+
@apply not-italic border-transparent relative;
86+
font-weight: inherit;
7887

79-
&:before {
80-
@apply content-[''] absolute -left-1 block transition bg-[var(--btn-regular-bg)] h-full w-1 rounded-full;
81-
}
82-
83-
/* Remove the double quotes from default styles */
84-
p:before, p:after {
85-
@apply content-none;
86-
}
88+
&:before {
89+
@apply content-[''] absolute -left-1 block transition bg-[var(--btn-regular-bg)] h-full w-1 rounded-full;
90+
}
8791

92+
/* Remove the double quotes from default styles */
93+
p:before,
94+
p:after {
95+
@apply content-none;
8896
}
97+
}
8998
}

src/styles/photoswipe.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
.pswp__button {
2-
@apply transition bg-black/40 hover:bg-black/50 active:bg-black/60 flex items-center justify-center mr-0 w-12 h-12 !important;
2+
@apply transition bg-black/40 hover:bg-black/50 active:bg-black/60 flex items-center justify-center mr-0 w-12 h-12 !important;
33
}
4-
.pswp__button--zoom, .pswp__button--close {
5-
@apply mt-4 rounded-xl active:scale-90 !important;
4+
.pswp__button--zoom,
5+
.pswp__button--close {
6+
@apply mt-4 rounded-xl active:scale-90 !important;
67
}
78
.pswp__button--zoom {
8-
@apply mr-2.5 !important;
9+
@apply mr-2.5 !important;
910
}
1011
.pswp__button--close {
11-
@apply mr-4 !important;
12+
@apply mr-4 !important;
1213
}

src/styles/scrollbar.css

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
.scrollbar-base.os-scrollbar {
2-
@apply transition-all;
3-
pointer-events: unset;
2+
@apply transition-all;
3+
pointer-events: unset;
44

5-
&.os-scrollbar-horizontal {
6-
@apply py-1 px-2 h-4;
7-
.os-scrollbar-track .os-scrollbar-handle {
8-
@apply rounded-full h-1;
9-
}
10-
&:hover .os-scrollbar-track .os-scrollbar-handle {
11-
@apply h-2;
12-
}
5+
&.os-scrollbar-horizontal {
6+
@apply py-1 px-2 h-4;
7+
.os-scrollbar-track .os-scrollbar-handle {
8+
@apply rounded-full h-1;
139
}
10+
&:hover .os-scrollbar-track .os-scrollbar-handle {
11+
@apply h-2;
12+
}
13+
}
1414

15-
&.os-scrollbar-vertical {
16-
@apply px-1 py-1 w-4;
17-
.os-scrollbar-track .os-scrollbar-handle {
18-
@apply rounded-full w-1;
19-
}
20-
&:hover .os-scrollbar-track .os-scrollbar-handle {
21-
@apply w-2;
22-
}
15+
&.os-scrollbar-vertical {
16+
@apply px-1 py-1 w-4;
17+
.os-scrollbar-track .os-scrollbar-handle {
18+
@apply rounded-full w-1;
19+
}
20+
&:hover .os-scrollbar-track .os-scrollbar-handle {
21+
@apply w-2;
2322
}
23+
}
2424
}
2525

2626
.os-scrollbar {
27-
&.scrollbar-auto {
28-
--os-handle-bg: var(--scrollbar-bg);
29-
--os-handle-bg-hover: var(--scrollbar-bg-hover);
30-
--os-handle-bg-active: var(--scrollbar-bg-active);
31-
}
32-
&.scrollbar-dark {
33-
--os-handle-bg: var(--scrollbar-bg-dark);
34-
--os-handle-bg-hover: var(--scrollbar-bg-hover-dark);
35-
--os-handle-bg-active: var(--scrollbar-bg-active-dark);
36-
}
37-
&.scrollbar-light {
38-
--os-handle-bg: var(--scrollbar-bg-light);
39-
--os-handle-bg-hover: var(--scrollbar-bg-hover-light);
40-
--os-handle-bg-active: var(--scrollbar-bg-active-light);
41-
}
27+
&.scrollbar-auto {
28+
--os-handle-bg: var(--scrollbar-bg);
29+
--os-handle-bg-hover: var(--scrollbar-bg-hover);
30+
--os-handle-bg-active: var(--scrollbar-bg-active);
31+
}
32+
&.scrollbar-dark {
33+
--os-handle-bg: var(--scrollbar-bg-dark);
34+
--os-handle-bg-hover: var(--scrollbar-bg-hover-dark);
35+
--os-handle-bg-active: var(--scrollbar-bg-active-dark);
36+
}
37+
&.scrollbar-light {
38+
--os-handle-bg: var(--scrollbar-bg-light);
39+
--os-handle-bg-hover: var(--scrollbar-bg-hover-light);
40+
--os-handle-bg-active: var(--scrollbar-bg-active-light);
41+
}
4242
}

src/utils/content-utils.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import { getCollection } from 'astro:content'
22
import type { BlogPostData } from '@/types/config'
33

4+
const getAllBlogPosts = async () => {
5+
const blogPosts = await getCollection('posts', ({ data }) => {
6+
return import.meta.env.PROD ? data.draft !== true : true
7+
})
8+
return blogPosts
9+
}
10+
411
export async function getSortedPosts(): Promise<
512
{ body: string; data: BlogPostData; slug: string }[]
613
> {
7-
const allBlogPosts = (await getCollection('posts', ({ data }) => {
8-
return import.meta.env.PROD ? data.draft !== true : true
9-
})) as unknown as { body: string; data: BlogPostData; slug: string }[]
10-
14+
const allBlogPosts = (await getAllBlogPosts()) as unknown as {
15+
body: string
16+
data: BlogPostData
17+
slug: string
18+
}[]
1119
const sorted = allBlogPosts.sort(
1220
(a: { data: BlogPostData }, b: { data: BlogPostData }) => {
1321
const dateA = new Date(a.data.published)
@@ -34,10 +42,7 @@ export type Tag = {
3442
}
3543

3644
export async function getTagList(): Promise<Tag[]> {
37-
const allBlogPosts = await getCollection<'posts'>('posts', ({ data }) => {
38-
return import.meta.env.PROD ? data.draft !== true : true
39-
})
40-
45+
const allBlogPosts = await getAllBlogPosts()
4146
const countMap: { [key: string]: number } = {}
4247
allBlogPosts.map((post: { data: { tags: string[] } }) => {
4348
post.data.tags.map((tag: string) => {
@@ -60,9 +65,7 @@ export type Category = {
6065
}
6166

6267
export async function getCategoryList(): Promise<Category[]> {
63-
const allBlogPosts = await getCollection<'posts'>('posts', ({ data }) => {
64-
return import.meta.env.PROD ? data.draft !== true : true
65-
})
68+
const allBlogPosts = await getAllBlogPosts()
6669
const count: { [key: string]: number } = {}
6770
allBlogPosts.map((post: { data: { category: string | number } }) => {
6871
if (!post.data.category) {

0 commit comments

Comments
 (0)