export async function onRequestGet(context) { const url = new URL(context.request.url); const path = url.pathname; // 首页 if (path === "/") { return fetch(new URL("/index.html", context.request.url)); } // sitemap(动态生成,不用上传大文件) if (path === "/sitemap.xml") { const host = url.origin; let xml = ` ${host}/ `; // 这里只生成示例,真正提交用你本地那个大 sitemap.xml xml += ``; return new Response(xml, { headers: { "Content-Type": "application/xml; charset=utf-8" } }); } // 关键词页面(动态生成) const keyword = decodeURIComponent(path.slice(1).replace(/-/g, " ")); const html = ` ${keyword} - 详细教程

${keyword}

本文为您提供 ${keyword} 相关专业内容。

`; return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } }); }