📢 新文章推送 · 每周更新优质内容 · 订阅更新 →
向下滚动
游戏娱乐

Encrypted Post

AI 智能总结

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---
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.

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

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.

版权声明

本文作者 Lumin

本文链接 https://www.zhengquan.xyz/game/encrypted-post/

许可协议 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!

请作者喝杯咖啡 ☕

  • 微信打赏
    微信支付
  • 支付宝打赏
    支付宝
点击按钮查看打赏二维码
🎁 推荐工具
试试这些实用在线工具,提升工作效率
前往工具集 →

留言评论

期待你的想法

评论加载中