Files
FastGPT/client/src/hooks/useMarkdown.ts
2023-06-09 13:21:03 +08:00

16 lines
363 B
TypeScript

import { useQuery } from '@tanstack/react-query';
export const getMd = async (url: string) => {
const response = await fetch(`/docs/${url}`);
const textContent = await response.text();
return textContent;
};
export const useMarkdown = ({ url }: { url: string }) => {
const { data = '' } = useQuery([url], () => getMd(url));
return {
data
};
};