ThemeKit
reblog提供了ThemeKit(@reblog/themekit)用以从后端获取数据。ThemeKit只提供数据,不约束实现,你可使用任意喜欢的框架配合ThemeKit开发主题。以下为ThemeKit API文档。
安装
使用包管理器:
pnpm add @reblog/themekit初始化 constructor
import ThemeKit from "@reblog/themekit";
 
const themekit = new ThemeKit({
  server: {
    url: "https://reblog.example.com",
  },
  cache: "no-store",
});文章
获取文章列表 getArticleList
const articles = await themekit.getArticleList({
  pageIndex: 1,
  pageSize: 10,
});根据slug获取文章 getArticle
const article = await themekit.getArticle("reblog-test-article");站点
获取站点信息 getSite
const site = await themekit.getSite();友链
获取友情链接 getFriendList
const friends = await themekit.getFriendList({
  pageIndex: 1,
  pageSize: 10,
});发起友链申请 addFriend
themekit.addFriend({
  name: "test site",
  avatar: "https://reblog.example.com/avatar.jpg",
  url: "https://reblog.example.com",
  desc: "reblog test site",
});类型声明
文章 Article
export type Article = {
  // 文章id
  id: number;
 
  // 文章创建时间
  created_at: string;
 
  // 文章更新时间
  updated_at: string;
 
  // 文章slug
  slug: string;
 
  // 文章标题
  title: string;
 
  // 文章描述
  desc: string;
 
  // 文章内容
  content: string;
};
 
export type ArticleList = {
  // 文章总数
  count: number;
 
  // 文章列表
  articles: Article[];
};站点 Site
export type Site = {
  name: string;
  url: string;
  desc: string;
  icon?: string;
};友链 Friend
export type Friend = {
  name: string;
  avatar: string;
  url: string;
  desc: string;
};