mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4mobile wallpaper 5mobile wallpaper 6
429 字
2 分钟
Encrypted Post
2024-01-15

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#

---
title: My First Blog Post
published: 2023-09-09
description: This is the first post of my new Astro blog.
image: ./cover.jpg
tags: [Foo, Bar]
category: Front-end
draft: false
---
AttributeDescription
titleThe title of the post.
publishedThe date the post was published.
pinnedWhether this post is pinned to the top of the post list.
descriptionA short description of the post. Displayed on index page.
imageThe cover image path of the post.
1. Start with http:// or https://: Use web image
2. Start with /: For image in public dir
3. With none of the prefixes: Relative to the markdown file
tagsThe tags of the post.
categoryThe category of the post.
aliasalias for the post. The post will be accessible at /posts/{alias}/. Example: my-special-article (will be available at /posts/my-special-article/)
licenseNameThe license name for the post content.
authorThe author of the post.
sourceLinkThe source link or reference for the post content.
draftIf this post is still a draft, which won’t be displayed.
encryptedWhether this post is password protected.
passwordThe password to unlock the encrypted post.
passwordHintA 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.

src/content/posts/
├── post-1.md
└── post-2/
├── cover.png
└── index.md

Posts alias#

You can set a alias for any post by adding the alias field to the front-matter:

---
title: My Special Article
published: 2024-01-15
alias: "my-special-article"
tags: ["Example"]
category: "Technology"
---

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#

graph LR A[User Password] --> B[Direct AES Decryption] B --> C{Check Prefix?} C -- "MIZUKI-VERIFY:" found --> D[Success: Render Content] 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:

---
title: My Private Post
published: 2024-01-15
encrypted: true
password: "my-secret-password"
passwordHint: "Hint: The password is my dog's name"
---

Fields#

FieldRequiredDescription
encryptedYesSet to true to enable password protection
passwordYesThe password to unlock the post
passwordHintNoA 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 passwordHint is 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.

分享

如果这篇文章对你有帮助,欢迎分享给更多人!

Encrypted Post
https://yoyolp.github.io/posts/encrypted-post/
作者
超级玉米人
发布于
2024-01-15
许可协议
CC BY-NC-SA 4.0

部分信息可能已经过时

目录