Something went wrong. Try again.
A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
Something went wrong. Try again.
12345678910111213141516171819202122232425import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';import { filesApi, type UpdateFileParams } from '../api/files';
export function useFileContent(owner: string, repo: string, path: string, branch?: string) { return useQuery({ queryKey: ['fileContent', owner, repo, path, branch], queryFn: () => filesApi.getFileContent(owner, repo, path, branch), enabled: !!owner && !!repo && !!path, });}
export function useUpdateFile() { const queryClient = useQueryClient();
return useMutation({ mutationFn: (params: UpdateFileParams) => filesApi.updateFile(params), onSuccess: (_, variables) => { // Invalidate the file content query to refetch queryClient.invalidateQueries({ queryKey: ['fileContent', variables.owner, variables.repo, variables.path], }); }, });}