halo
halo copied to clipboard
新增文章模块
Your current Halo version
2.0.0
Describe this feature
文章模块包含:文章 分类 标签 评论
文章模型
文章可用排序策略:创建时间,文章热度,更新时间,最后回复时间
每篇文章对应一个 permalink 规则如下
/permalink/posts/{post-name}
kind: Post
apiVersion: content.halo.run/v1alpha1
metadata:
name: post-slug-name
annotations:
html-metas: "<html-meta-here>" # https://ogp.me,可以根据 spec.htmlMetas生成一些默认 meta
spec:
versioin: 1
release-snapshot: "xxx" # 关联已发布的内容快照
head-snapshot: "xx" # 当前引用的内容快照,更新时会使用它
base-snapshot: "xx" # 内容基快照名
title: "post title" # 文章标题
owner: "an-username"
deleted: false # 是否已逻辑删除标记
visible: "public" # public | internal | private
published: false # 已发布
pinned: false # 是否置顶
priority: 0 # 置顶排序字段
htmlMetas: # List<Map<String,String>>
- name: "keywords"
content: "insert,some,keywords,here"
charset: utf8
excerpt:
autoGenerate: true # 自动生成摘要
content: "post excerpt" # 文章摘要内容
allowComment: true # 是否开启评论
template: "post.html" # 渲染模板
cover: "" # 封面图
categories: # 文类名
- category-name-1
tags: # 标签名
- tag-name-1
status:
phase: "draft" # draft -> pending-approval -> published
permalink: /posts/slug-name
excerpt: "最终摘要"
in-progress: false # 是否有内容正在进行中
contributors: # 文章的所有贡献者
- zhangsan
- lisi
文章统计相关内容待定
stats: # 文章统计
upvote: 5 # 点赞数
views: 362 # 浏览量
commentCount: 4 # 文章评论数
lastReplyTime: xxx # 最后回复时间,可以用于排序
Category 模型
每个分类对应一个 permalink 规则如下:
/permalink/categories/{category-name}
kind: Category
apiVersion: content.halo.run/v1alpha1
metadata:
name: category-name
annotations:
content.halo.run/icon: "an-icon"
spec:
children: # 子分类名称 depth=1
- one
- two
displayName: category-display-name
description: "分类描述"
priority: 0
cover: "封面图"
template: "category.html" # 渲染模板
status:
posts: [] # 包括当前和其下所有层级的文章 name (depth=max)
Tag 模型
每个 Tag 对应一个 permalink 规则如下:
/permalink/tags/{tag-name}
kind: Tag
apiVersion: content.halo.run/v1alpha1
metadata:
name: tag-name
annotations:
content.halo.run/icon: "an-icon"
spec:
displayName: tag-display-name
color: "#cfd3d7"
cover: "http://example.com" #封面图
status:
posts: [] # 引用了此 Tag 的所有文章
公共模型 Snapshot: 内容的快照
kind: Snapshot
apiVersion: content.halo.run/v1alpha1
metadata:
name: a-snapshot-generated-name
spec:
subjectRef:
kind: Post # Post | Journal
name: "hello-halo"
rawType: "MARKDOWN" # markdown | html | json | asciidoc | latex
rawPatch: "[{}]" # 原始内容差异补丁
contentPatch: "[{}]" # 渲染后的内容差异补丁
version: 1 # 快照版本号
display-version: "v1" # 版本显示名
publish-time: "xxx" # 内容发布时间
parent-snapshot-name: "parent-snapshot-genertated-name" # 上一级快照名
公共模型 Comment:
kind: Comment
apiVersion: content.halo.run/v1alpha1
metadata:
name: generated-comment-named
spec:
raw: "" # 原始内容
content: "<p>content<p>" # 评论内容 html
subjectRef:
kind: Post # Post | Journal | Page
name: "a-post-name"
#upvote: 123 # 点赞,统计信息待定
#downvote: 123 # 踩
owner: # 评论创建人
kind: Email # Email | User
name: "[email protected]"
displayName: "xxx" # kind 为 User 则不设置
annotations:
website: "xxx"
avatar: "xx"
top: false # 是否置顶
priority: 0 # 置顶排序,非置顶按评论时间或热度排序
userAgent: ""
ipAddress: ""
allow-notification: "true" # 是否允许通知
approved: false # 是否已审核通过
hidden: false # 是否在主题端显示
公共模型,评论回复模型 Reply:
kind: Reply
apiVersion: content.halo.run/v1alpha1
metadata:
name: generated-reply-named
spec:
raw: "" # 原始内容
content: "<p>content<p>" # 回复内容 html
#upvote: 123 # 点赞
#downvote: 123 # 踩
owner: # 回复创建人
kind: Email # Email | User
name: "[email protected]"
displayName: "xxx"
annotations:
website: "xxx"
avatar: "xx"
quoteReply: "generated-reply-named" # 回复对象
commentName: "" # 评论名,对应 Comment 模型的记录
top: false
priority: 0
userAgent: ""
ipAddress: ""
top-comment-name: "" # 所属一级评论名,为空则表示当前为一级评论
allow-notification: "true" # 是否允许通知
approved: false # 是否审核通过
hidden: false # 是否在主题端展示
评论示例:
lisi:这是一条评论
|- zhangsan:这是一级评论的回复
|- wangwu@zhangsan: 这是回复的回复
Additional information
/area core /milestone 2.0 /kind feature /assign