This blog template is built with Astro. For the things that are not mentioned in this guide, you may find the answers in the Astro Docs.
Front-matter of Posts
1---
2title: My First Blog Post
3published: 2023-09-09
4description: This is the first post of my new Astro blog.
5image: ./cover.jpg
6tags: [Foo, Bar]
7category: Front-end
8draft: false
9---
| Attribute | Description |
|---|---|
title | The title of the post. |
published | The date the post was published. |
pinned | Whether this post is pinned to the top of the post list. |
description | A short description of the post. Displayed on index page. |
image | The cover image path of the post. 1. Start with http:// or https://: Use web image2. Start with /: For image in public dir3. With none of the prefixes: Relative to the markdown file |
tags | The tags of the post. |
category | The category of the post. |
alias | alias for the post. The post will be accessible at /posts/{alias}/. Example: my-special-article (will be available at /posts/my-special-article/) |
licenseName | The license name for the post content. |
author | The author of the post. |
sourceLink | The source link or reference for the post content. |
draft | If this post is still a draft, which won’t be displayed. |
encrypted | Whether this post is password protected. |
password | The password to unlock the encrypted post. |
passwordHint | A hint to help users remember the password. Displayed below the password input. |
Where to Place the Post Files
Your post files should be placed in src/content/posts/ directory. You can also create sub-directories to better organize your posts and assets.
1src/content/posts/
2├── post-1.md
3└── post-2/
4 ├── cover.png
5 └── index.md
Posts alias
You can set a alias for any post by adding the alias field to the front-matter:
1---
2title: My Special Article
3published: 2024-01-15
4alias: "my-special-article"
5tags: ["Example"]
6category: "Technology"
7---
When a alias is set:
- The post will be accessible at the custom URL (e.g.,
/posts/my-special-article/) - The default
/posts/{slug}/URL will still work - RSS/Atom feeds will use the custom alias
- All internal links will automatically use the custom alias
Important Notes:
- Alias should NOT include
/posts/prefix (it will be added automatically) - Avoid special characters and spaces in alias
- Use lowercase letters and hyphens for best SEO practices
- Make sure alias are unique across all posts
- Don’t include leading or trailing slashes
How It Works
1graph LR
2 A[User Password] --> B[Direct AES Decryption]
3 B --> C{Check Prefix?}
4 C -- "MIZUKI-VERIFY:" found --> D[Success: Render Content]
5 C -- Random/Garbage --> E[Fail: Wrong Password]
Page Encryption
You can password protect any post by setting encrypted: true and providing a password in the front-matter:
1---
2title: My Private Post
3published: 2024-01-15
4encrypted: true
5password: "my-secret-password"
6passwordHint: "Hint: The password is my dog's name"
7---
Fields
| Field | Required | Description |
|---|---|---|
encrypted | Yes | Set to true to enable password protection |
password | Yes | The password to unlock the post |
passwordHint | No | A hint displayed below the password input to help users |
How the Unlock Box Looks
The unlock box displays:
- A lock icon in the theme’s primary color
- The post title “Password Protected”
- A description asking for the password
- A hint (if
passwordHintis provided) - A password input field and unlock button
After entering the correct password, the content is decrypted and displayed. The password is stored in session storage so users don’t need to re-enter it on subsequent page loads within the same session.
留言评论
期待你的想法评论加载中