Skip to content

Commit 7134eb4

Browse files
author
hulinjiang
committed
使用 slug 而不是 title 定位文章路径
1 parent cd44c9f commit 7134eb4

11 files changed

Lines changed: 61 additions & 11 deletions

File tree

packages/pure/components/pages/PostPreview.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const postDate = data.updatedDate ?? data.publishDate
3737
!detailed && 'sm:flex-row',
3838
detailed && data.heroImage && 'max-md:pt-24'
3939
)}
40-
href={`/blog/${id}`}
40+
href={`/blog/${data.slug}`}
4141
data-astro-prefetch
4242
>
4343
{

src/content.config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { defineCollection, z } from 'astro:content';
22
import { glob } from 'astro/loaders';
33

4-
5-
6-
7-
84
function removeDupsAndLowerCase(array: string[]) {
95
if (!array.length) return array
106
const lowercaseItems = array.map((str) => str.toLowerCase())
@@ -20,6 +16,7 @@ const blog = defineCollection({
2016
z.object({
2117
// Required
2218
title: z.string().max(60),
19+
slug: z.string(),
2320
description: z.string().max(160).optional(),
2421
publishDate: z.coerce.date(),
2522
// Optional

src/content/blog/coding/01_位运算.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ heroImage:
1313
src: ./attachments/bit_op.png
1414
color: '#188a3e'
1515
toc: 1
16+
slug: c1
1617
---
1718

1819
import Aside from '@/custom/components/user/Aside.astro'

src/content/blog/coding/bloom_filter.mdx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ai-model:
1212
- gemini-2.5-pro
1313
heroImage:
1414
src: ./attachments/bloom_filter_2.png
15+
slug: c2
1516
---
1617

1718
import Paper from '@/custom/components/pages/Paper.astro'
@@ -270,3 +271,53 @@ The astro-theme-pure theme is open source under the [Apache 2.0](https://github.
270271
- **空间效率高**:相比于传统的集合数据结构,布隆过滤器使用更少的内存来存储相同数量的元素。
271272
- **查询速度快**:布隆过滤器的查询操作非常快速,通常是常数时间复杂度。
272273

274+
275+
import Signature from 'src/assets/signature.svg'
276+
277+
<Signature mode='loop'/>
278+
279+
280+
{/* // import { MdxRepl } from 'astro-pure/user' */}
281+
282+
# Signature
283+
284+
> Thanks for [zhuozhiyongde (Arthals)](https://github.com/zhuozhiyongde)
285+
>
286+
> https://github.com/cworld1/astro-theme-pure/commit/695e722d7d537adb7f1b2893452328e09581b995
287+
288+
<MdxRepl>
289+
{/* // import Signature from '<place_file_path>' */}
290+
291+
{/* // <Signature /> */}
292+
293+
<Fragment slot='desc'>
294+
```jsx
295+
import Signature from '<place_file_path>'
296+
297+
<Signature />
298+
```
299+
</Fragment>
300+
</MdxRepl>
301+
302+
To customize this component, you first need to create an SVG using Figma or another vector graphics editor. This SVG should contain one or more `<path>` elements with a `stroke` attribute, as the animation effect is applied exclusively to these stroked paths. You can refer to [this SVG](https://github.com/zhuozhiyongde/Arthals-Ink/blob/main/src/assets/signature.svg) as an example.
303+
304+
There also has some additional attributes you can use to customize the component:
305+
306+
1. `data-duration`(optional): The duration of the animation in milliseconds. If not specified, the `defaultDuration` prop value will be used. For example: `<path data-duration="800" ... />`
307+
2. `seq`(optional): The sequence of the path. If not specified, the path will be animated in the order of appearance in the SVG file. For example: `<path seq="1" ... />`, `<path seq="2" ... />`.
308+
309+
By default, the component loads the SVG file from `src/assets/signature.svg`. Place your prepared SVG file at this path and name it `signature.svg`.
310+
311+
## Component Props
312+
313+
You can pass the following props when using the component to customize its animation behavior:
314+
315+
| Prop | Type | Description | Default Value |
316+
| ----------------- | ---------------------------- | ------------------------------------------------------------ | ------------- |
317+
| `mode` | `'loop'` \| `'once-on-view'` | Animation mode. `loop`: continuously draws and rolls back; `once-on-view`: plays the animation once it enters the viewport. | `'loop'` |
318+
| `drawDelay` | `number` | (Loop mode) The delay in milliseconds before drawing the next path. | `200` |
319+
| `rollbackDelay` | `number` | (Loop mode) The delay in milliseconds before rolling back the previous path. | `80` |
320+
| `loopPause` | `number` | (Loop mode) The pause duration in milliseconds at the end of each full cycle. | `2000` |
321+
| `threshold` | `number` | (On-view mode) The visibility threshold (from 0.0 to 1.0) to trigger the animation. | `1.0` |
322+
| `defaultDuration` | `number` | The default animation duration in milliseconds for each stroke. | `600` |
323+
| `class` | `string` | Additional CSS classes to be added to the component's root element. | `undefined` |

src/content/blog/markdown/icon.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tags:
66
- icons
77
heroImage: { src: './thumbnail.jpg', color: '#c8d57fff' }
88
language: 'English'
9+
slug: m1
910
---
1011

1112
import { Icon } from '@/custom/components/user/index'

src/content/blog/markdown/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ tags:
66
- Markdown
77
heroImage: { src: './thumbnail.jpg', color: '#c8d57fff' }
88
language: 'English'
9-
redirect_from:
10-
- m1
9+
slug: m2
1110
---
1211

1312
## Basic Syntax

src/content/blog/test/b.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: 'astro-theme-pure Personalized Customization Guide'
55
tags:
66
- test
77
language: 'English'
8+
slug: t1
89
---
910

1011

src/content/blog/test/paper.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tags:
66
- test
77
heroImage: { src: './paper.png'}
88
language: '中文'
9+
slug: t2
910
---
1011

1112
import Paper from '@/custom/components/pages/Paper.astro'

src/content/blog/test/test_code.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tags:
66
- test
77
- expressive-code
88
language: 'english'
9+
slug: t3
910
---
1011
import { MdxRepl, TabItem, Tabs } from 'astro-pure/user'
1112

src/content/blog/test/test_inner_link.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ tags:
77
language: 'english'
88
ai-model:
99
- gemini-2.5-pro
10-
redirect_from:
11-
- hhh
12-
- ggg
10+
slug: t4
1311
---
1412

1513
**我 bqweq**

0 commit comments

Comments
 (0)