Skip to content

Commit be0097d

Browse files
authored
Merge pull request #2168 from fatihbaltaci/master
Introducing Gurubase for Permify Docs
2 parents a5efe9d + 9414868 commit be0097d

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
<a href="https://img.shields.io/github/commit-activity/m/Permify/permify?style=for-the-badge" target="_blank"><img src="https://img.shields.io/github/commit-activity/m/Permify/permify?style=for-the-badge" alt="Permify Commit Activity" /></a>&nbsp;
2727
<a href="https://img.shields.io/github/actions/workflow/status/Permify/permify/release.yml?style=for-the-badge" target="_blank"><img src="https://img.shields.io/github/actions/workflow/status/Permify/permify/release.yml?style=for-the-badge" alt="GitHub Workflow Status" /></a>&nbsp;
2828
<a href="https://scrutinizer-ci.com/g/Permify/permify/?branch=master" target="_blank"><img src="https://img.shields.io/scrutinizer/quality/g/Permify/permify/master?style=for-the-badge" alt="Scrutinizer code quality (GitHub/Bitbucket)" /></a>&nbsp;
29-
<a href='https://coveralls.io/github/Permify/permify?branch=master'><img alt="Coveralls" src="https://img.shields.io/coverallsCoverage/github/Permify/permify?style=for-the-badge"></a>
29+
<a href='https://coveralls.io/github/Permify/permify?branch=master'><img alt="Coveralls" src="https://img.shields.io/coverallsCoverage/github/Permify/permify?style=for-the-badge"></a>&nbsp;
30+
<a href="https://gurubase.io/g/permify" target="_blank"><img src="https://img.shields.io/badge/Gurubase-Ask%20AI-006BFF?style=for-the-badge" alt="Gurubase - Ask AI" /></a>
31+
3032
</p>
3133

3234
![permify-centralized](https://github.com/user-attachments/assets/124eaa43-5d33-423d-a258-5d6f4afbc774)

docs/gurubase.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Customize widget settings
2+
const widgetSettings = {
3+
widgetId: "VD4cSN50VRpdWDIeSpVeYaQYiaND85NwIDv7ppAByDw", // Use different widget ID for localhost - https://gurubase.io/guru/permify/integrations/web_widget
4+
overlapContent: true,
5+
// Optional configurations:
6+
// text: "Ask AI", // Button text
7+
// margins: { bottom: "20px", right: "20px" }, // Widget positioning
8+
// lightMode: false, // Force light mode
9+
// name: "YOUR_NAME", // Widget name
10+
// iconUrl: "YOUR_ICON_URL", // Widget icon URL
11+
// bgColor: "#000000", // Widget background color
12+
};
13+
14+
// Load the GuruBase widget
15+
const guruScript = document.createElement("script");
16+
guruScript.src = "https://widget.gurubase.io/widget.latest.min.js";
17+
guruScript.defer = true;
18+
guruScript.id = "guru-widget-id";
19+
20+
// Add widget settings as data attributes
21+
Object.entries(widgetSettings).forEach(([key, value]) => {
22+
const dataKey = `data-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
23+
const dataValue = typeof value === 'object' ? JSON.stringify(value) : value;
24+
guruScript.setAttribute(dataKey, dataValue);
25+
});
26+
27+
// Initialize theme handling
28+
guruScript.addEventListener('load', () => {
29+
const initWidget = setInterval(() => {
30+
if (window.chatWidget?.switchTheme) {
31+
clearInterval(initWidget);
32+
33+
// Handle theme changes
34+
const syncTheme = () => {
35+
const isDark = document.documentElement.classList.contains('dark');
36+
window.chatWidget.switchTheme(!isDark);
37+
};
38+
39+
// Watch for theme changes
40+
new MutationObserver(syncTheme).observe(document.documentElement, {
41+
attributes: true,
42+
attributeFilter: ['class']
43+
});
44+
45+
// Set initial theme
46+
syncTheme();
47+
}
48+
}, 1000);
49+
50+
// Stop checking after 20 seconds
51+
setTimeout(() => clearInterval(initWidget), 20000);
52+
});
53+
document.body.appendChild(guruScript);

docs/mint.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,5 +420,10 @@
420420
"twitter": "https://twitter.com/getPermify",
421421
"github": "https://github.com/Permify/permify",
422422
"linkedin": "https://www.linkedin.com/company/permifyco"
423-
}
423+
},
424+
"scripts": [
425+
{
426+
"src": "/gurubase.js"
427+
}
428+
]
424429
}

0 commit comments

Comments
 (0)