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({
trademark: false,
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 参考
客户端工厂
框架客户端方法
配置选项
选项卡
选项卡操作
操作欢迎词
欢迎词建议
建议商标
商标工具
工具访客 (认证访问)
访客 (认证访问)常见陷阱
最后更新于
这有帮助吗?