Node.js/NPM
使用 NPM 包集成 Docs Embed,以实现完整的应用级控制
步骤
2
4
创建一个 iframe
const iframe = document.createElement("iframe");
iframe.src = gitbook.getFrameURL({
visitor: {
token: 'your-jwt-token', // 可选:用于自适应内容或经过身份验证的访问
unsignedClaims: { // 可选:用于动态表达式的自定义声明
userId: '123',
plan: 'premium'
}
}
});
iframe.id = "gitbook-embed-container";
iframe.style.border = "none";
iframe.style.width = "100%";
iframe.style.height = "600px";5
6
7
配置嵌入
frame.configure({
tabs: ['assistant', 'docs'],
actions: [
{
icon: 'circle-question',
label: 'Contact Support',
onClick: () => window.open('https://support.example.com', '_blank')
}
],
greeting: { title: 'Welcome!', subtitle: 'How can I help?' },
suggestions: ['What is GitBook?', 'How do I get started?'],
tools: [/* ... */]
});API 参考
客户端工厂
框架客户端方法
配置选项
tabs
tabsactions
actionsgreeting
greetingsuggestions
suggestionstools
toolsvisitor (经过身份验证的访问)
visitor (经过身份验证的访问)常见错误
最后更新于
这有帮助吗?