Shiro 渲染leetcode卡片
最新版的Shiro已经兼容的leetcode的卡片,但是因为leetcode的api需要后台获取数据,这里使用mx-space的云函数来嫁接请求
为什么要弯弯绕绕,不直接在服务端获取数据后渲染,好像是渲染markdown的逻辑是客户端,所以获取数据也是在客户端进行,无法利用ssr的优势
先记录一下吧,方便后续迁移
export default async function handler(ctx: Context) {
const requestBody =ctx.req.body
// 通用的 GraphQL 请求函数
const response = await fetch('https://leetcode.cn/graphql/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
});
if (!response.ok) {
throw new Error('Failed to fetch data from LeetCode API');
}
return await response.json();
}
云函数配置信息

image-20241013231352625