A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
at main 35 lines 938 B view raw
1import { apiClient } from './client'; 2import type { FileContent } from '../types/api'; 3 4export interface UpdateFileParams { 5 owner: string; 6 repo: string; 7 path: string; 8 content: string; 9 frontmatter: Record<string, any>; 10} 11 12export const filesApi = { 13 async getFileContent( 14 owner: string, 15 repo: string, 16 path: string, 17 branch?: string 18 ): Promise<FileContent> { 19 const params = branch ? { branch } : {}; 20 const response = await apiClient.get<FileContent>( 21 `/api/repos/${owner}/${repo}/files/${path}`, 22 { params } 23 ); 24 return response.data; 25 }, 26 27 async updateFile(params: UpdateFileParams): Promise<{ success: boolean; draft_saved: boolean; saved_at: string }> { 28 const { owner, repo, path, content, frontmatter } = params; 29 const response = await apiClient.put( 30 `/api/repos/${owner}/${repo}/files/${path}`, 31 { content, frontmatter } 32 ); 33 return response.data; 34 }, 35};