import GhostContentAPI from '@tryghost/content-api'; export const GHOST_URL = 'https://admin.blog.nanao.moe'; const GHOST_KEY = '8c86e852c31b39b9d4148b2088'; const GHOST_VERSION = 'v5.0'; const api = GhostContentAPI({ url: GHOST_URL, key: GHOST_KEY, version: GHOST_VERSION }) export const browsePost = async (page = 1) => { const posts = await api.posts.browse({ page: page, limit: 10, include: ['tags', 'authors'] }); return posts } export const browseAllPost = async (page = 1) => { const posts = await api.posts.browse({ limit: 'all' }); return posts } export const browsePostWithTag = async (slug: string, page = 1) => { const posts = await api.posts.browse({ page: page, limit: 10, include: ['tags', 'authors'], filter: [`tag:${slug}`] }); return posts } export const browsePostWithAuthor = async (slug: string, page = 1) => { const posts = await api.posts.browse({ page: page, limit: 10, include: ['tags', 'authors'], filter: [`author:${slug}`] }); return posts } export const readPost = async (slug: string) => { const post = await api.posts.read({ slug }, { include: ['tags', 'authors'] }); return post; } export const readTag = async (slug: string) => { const tag = await api.tags.read({ slug }); return tag; } export const readAuthor = async (slug: string) => { const author = await api.authors.read({ slug }); return author; } export const browseLatestPost = async () => { const post = await api.posts.browse({ limit: 1 }); return post[0]; } export const browseLatestTag = async () => { const tag = await api.tags.browse({ limit: 1, order: 'updated_at DESC' }) } export const browseLatestAuthor = async () => { const tag = await api.authors.browse({ limit: 1, order: 'updated_at DESC' }) } export const browseSettings = async () => { return { codeinjection_head: ``, codeinjection_foot: ``, }; }