@writedocs/generator 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@writedocs/generator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Static site generator for docs — a writedocs.json + MDX folder in, a static site out.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -84,4 +84,4 @@
|
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"esbuild": "0.28.2"
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|
|
@@ -25,11 +25,17 @@ interface Props {
|
|
|
25
25
|
const { config } = Astro.props as Props;
|
|
26
26
|
|
|
27
27
|
const askAiLoaderScript = `window.DocsBotAI=window.DocsBotAI||{},DocsBotAI.init=function(e){return new Promise((t,r)=>{var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://widget.docsbot.ai/chat.js";let o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o),n.addEventListener("load",()=>{let n;Promise.all([new Promise((t,r)=>{window.DocsBotAI.mount(Object.assign({}, e)).then(t).catch(r)}),(n=function e(t){return new Promise(e=>{if(document.querySelector(t))return e(document.querySelector(t));let r=new MutationObserver(n=>{if(document.querySelector(t))return e(document.querySelector(t)),r.disconnect()});r.observe(document.body,{childList:!0,subtree:!0})})})("#docsbotai-root"),]).then(()=>t()).catch(r)}),n.addEventListener("error",e=>{r(e.message)})})};`;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// WRITEDOCS_ASK_AI_ID tem precedência sobre o writedocs.json, pelo mesmo
|
|
29
|
+
// motivo do WRITEDOCS_DISABLE_WATERMARK em Sidebar.astro: quem roda o build
|
|
30
|
+
// (CI, env da hospedagem) define o bot sem mexer no conteúdo versionado.
|
|
31
|
+
// Não é segredo - o id sai em texto puro no HTML de toda página. String
|
|
32
|
+
// vazia conta como não definida e cai no valor do JSON.
|
|
33
|
+
const askAiId = process.env.WRITEDOCS_ASK_AI_ID || config.integrations.askAi?.id;
|
|
34
|
+
const askAiInitScript = askAiId
|
|
35
|
+
? `DocsBotAI.init(${JSON.stringify({ id: askAiId })});`
|
|
30
36
|
: null;
|
|
31
37
|
---
|
|
32
|
-
{
|
|
38
|
+
{askAiId && (
|
|
33
39
|
<>
|
|
34
40
|
<script is:inline set:html={askAiLoaderScript} />
|
|
35
41
|
{askAiInitScript && <script is:inline set:html={askAiInitScript} />}
|