@ dualmark/ 核心
AEO(Answer引擎优化)基础设施的框架-不可知原始.
零运行时间依赖关系. EME + CJS. 严格类型脚本.
安装
bun add @dualmark/core
里面有什么东西
- 内容谈判 (单位:千美元)
parseAcceptHeader, (中文(简体) ),negotiateFormat— RFC 7231 § 5.3.2 符合 - AI 机器人检测 (单位:千美元)
detectAIBot, (中文(简体) ),AI_BOTS——24名已知爬行者登记,并附有供应商+目的元数据 - 标记响应 (单位:千美元)
markdownResponse, (中文(简体) ),injectMarkdownAlternateLink)——建设Response带有所有 AEO 标题的对象 - 路径公用事业 (单位:千美元)
toMarkdownPath, (中文(简体) ),toMarkdownUrl) ——将 HTML 路径/URLs 转换为被标记的双胞胎 - 托肯估计 (单位:千美元)
estimateTokens) —— 默认为空白- 分割 - 文本公用事业 (单位:千美元)
normalizeUnicode, (中文(简体) ),cleanBody, (中文(简体) ),slugToTitle, (中文(简体) ),fmtDate, (中文(简体) ),joinLines)——用于写下标记转换器 - 构成帮助者 (单位:千美元)
listingToMarkdown, (中文(简体) ),renderRelatedLinks, (中文(简体) ),renderFAQSection(中文(简体) ) - llms.txt 渲染 (单位:千美元)
renderLlmsTxt(中文(简体) )
快速实例
import { negotiateFormat, markdownResponse, detectAIBot } from "@dualmark/core";
export default {
async fetch(request) {
const accept = request.headers.get("accept") ?? "";
const ua = request.headers.get("user-agent") ?? "";
const bot = detectAIBot(ua);
const fmt = negotiateFormat(accept);
if (fmt === null) return new Response("Not Acceptable", { status: 406 });
if (bot.isBot || fmt === "markdown") {
return markdownResponse("# Hello\n\nThis is the markdown twin.");
}
return new Response("<html><body>Hello</body></html>", {
headers: { "Content-Type": "text/html" },
});
},
};
许可证
Apache 2.0 — 见 自由主义。 。 。 .
光谱
此软件包执行 AEO 规格 v1.0。 。 。 .