Skip to main content

yggdrasil/api/posts/
mod.rs

1//! 文章模块:提供文章的 CRUD、列表、搜索、标签聚合与统计等 server function。
2//!
3//! 所有 Leptos server function 均注册在 `/api` 路径下,供前端与服务端调用。
4//! 仅在 `feature = "server"` 启用的服务端构建中执行数据库操作与缓存失效。
5
6#![allow(clippy::unused_unit, deprecated, unused_imports)]
7
8mod archive;
9mod batch;
10mod create;
11mod delete;
12pub(crate) mod helpers;
13mod list;
14mod mermaid_preview;
15mod outline;
16mod read;
17mod rebuild;
18mod roundtrip;
19mod search;
20#[cfg(feature = "server")]
21pub(crate) mod service;
22mod stats;
23mod suggest;
24mod tags;
25mod trash;
26mod types;
27mod update;
28#[cfg(feature = "server")]
29mod validation;
30
31pub use archive::{
32    list_archive_posts, posts_per_year, ArchiveResponse, YearCount, ARCHIVE_PAGE_SIZE,
33};
34/// 后台列表批量操作(转为草稿、移到回收站)。
35pub use batch::batch_posts;
36/// 创建新文章。
37pub use create::create_post;
38/// 删除指定文章。
39pub use delete::delete_post;
40/// 获取回收站中已软删除的文章列表。
41pub use list::list_deleted_posts;
42/// 获取管理员视角的全部文章分页列表。
43pub use list::list_posts;
44/// 获取已发布文章分页列表。
45pub use list::{get_posts_by_tag, list_published_posts};
46/// 后台编辑器的 Mermaid 预览(服务端渲染)。
47pub use mermaid_preview::render_mermaid_preview;
48/// 首页最新一篇的目录预览。
49pub use outline::latest_post_outline;
50/// 根据 id 获取文章详情。
51/// 根据 slug 获取已发布文章详情(公开)。
52/// 按 slug 预览文章(管理员,含草稿)。
53pub use read::{get_post_by_id, get_post_by_slug, get_post_preview, get_public_post_by_slug};
54/// 重新渲染文章的 Markdown HTML 与目录。
55pub use rebuild::rebuild_content_html;
56/// 重新渲染指定文章的 Markdown HTML 与目录(单篇)。
57pub use rebuild::rebuild_post_content_html;
58/// 富文本编辑器往返渲染一致性检查。
59pub use roundtrip::check_markdown_roundtrip;
60/// 全文搜索已发布文章。
61pub use search::search_posts;
62/// 获取文章统计信息。
63pub use stats::get_post_stats;
64#[cfg(feature = "server")]
65pub(crate) use stats::load_post_stats;
66#[cfg(feature = "server")]
67pub(crate) use suggest::query_suggestions;
68/// 搜索面板(⌘K)的文章建议。
69pub use suggest::{recommend_for_path, suggest_posts, PathRecommendations};
70/// 获取全部标签及其文章数量。
71pub use tags::list_tags;
72/// 恢复已删除文章。
73pub use trash::{batch_purge_posts, batch_restore_posts, empty_trash, purge_post, restore_post};
74/// 文章 API 的请求与响应数据结构。
75pub use types::*;
76/// 更新指定文章。
77pub use update::update_post;
78
79#[cfg(feature = "server")]
80pub(crate) use trash::restore_post_impl;