import {useApi} from '@common/api/useApi.ts';
import {z} from 'zod';

const articleSchema = z.object({
  content: z.string({
    required_error: '文章内容不存在',
    invalid_type_error: '文章内容类型错误',
  }), // 文章内容
  title: z.string(), // 文章标题
  publishTime: z.string().optional(), // 发布时间
  coverImgUrl: z.string().optional(), // 封面图
  shareUrl: z.string().optional(), // 分享链接
  summary: z.string().optional(), // 摘要
});

// 首页文章详情
const useArticleDetail = (id: string) => {
  return useApi(
    '/am/v3/hotnews/article/detail',
    'GET',
    {
      id: id,
    },
    articleSchema,
    {},
  );
};

export {useArticleDetail};
