Skip to content

Commit 21a0a16

Browse files
committed
feature(discovery): add Trieve search and AI chat to the docs (old Mintlify functionality)
1 parent e969dfe commit 21a0a16

File tree

5 files changed

+132
-5
lines changed

5 files changed

+132
-5
lines changed

.github/workflows/update-trieve.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update Trieve
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.head_ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Install Trieve Fern Adapter
20+
run: npm install -g trieve-vitepress-adapter
21+
22+
- name: Update Trieve Chunks
23+
env:
24+
TRIEVE_API_HOST: ${{ secrets.TRIEVE_API_HOST }}
25+
TRIEVE_API_KEY: ${{ secrets.TRIEVE_API_KEY }}
26+
TRIEVE_ORGANIZATION_ID: ${{ secrets.TRIEVE_ORGANIZATION_ID }}
27+
TRIEVE_DATASET_TRACKING_ID: ${{ secrets.TRIEVE_DATASET_TRACKING_ID }}
28+
run: trieve-vitepress-adapter --path . -s https://coolify.io/docs/openapi.json -r https://coolify.io -a docs/api-reference/api/operations

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ examples-temp
1515
node_modules
1616
pnpm-global
1717
TODOs.md
18-
*.timestamp-*.mjs
18+
*.timestamp-*.mjs
19+
.env

docs/.vitepress/config.mts

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export default defineConfig({
4545
['meta', { property: 'twitter:description', content: 'Self hosting with superpowers: An open-source & self-hostable Heroku / Netlify / Vercel alternative.' }],
4646
['meta', { property: 'twitter:url', content: 'https://coolify.io/docs/' }],
4747
['meta', { property: 'twitter:image', content: 'https://coolcdn.b-cdn.net/assets/coolify/og-image-docs.png' }],
48-
['link', { rel: 'icon', href: 'coolify-logo-transparent.png' }],
48+
['link', { rel: 'icon', href: '/docs/coolify-logo-transparent.png' }],
4949
['script', { src: 'https://analytics.coollabs.io/js/script.js', 'data-domain': 'coolify.io/docs' }],
50+
['script', { async: 'true', src: '/docs/trieve-user-script.js' }],
5051
],
5152
themeConfig: {
5253
// https://vitepress.dev/reference/default-theme-config
@@ -603,7 +604,7 @@ export default defineConfig({
603604
plugins: [
604605
yaml as any,
605606
llms({
606-
llmsDir: '/'
607+
llmsDir: './'
607608
})
608609
],
609610
assetsInclude: ['**/*.yml'],

docs/.vitepress/theme/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "./tailwind.postcss";
1919
import "vitepress-openapi/dist/style.css";
2020

2121
// @ts-ignore
22-
import spec from '../../public/openapi.json' assert { type: 'json' }
22+
import spec from "../../public/openapi.json" assert { type: "json" };
2323

2424
// Import components
2525
import Card from "./components/Card.vue";
@@ -42,7 +42,7 @@ export default {
4242
const openapi = useOpenapi({
4343
spec,
4444
base: "/docs/api-reference/api/operations/",
45-
label: "API"
45+
label: "API",
4646
});
4747

4848
theme.enhanceApp({ app, openapi });

docs/public/trieve-user-script.js

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// ==UserScript==
2+
// @name Coolify
3+
// @namespace http://tampermonkey.net/
4+
// @version 2025-01-16
5+
// @description try to take over the world!
6+
// @author You
7+
// @match https://coolify.io/docs/*
8+
// @icon https://www.google.com/s2/favicons?sz=64&domain=coolify.io
9+
// @grant none
10+
// ==/UserScript==
11+
12+
const removeAllClickListeners = (element) => {
13+
const newElement = element.cloneNode(true);
14+
element.parentNode.replaceChild(newElement, element);
15+
return newElement;
16+
};
17+
18+
const makeDefaultSearchTrieve = async () => {
19+
let defaultSearchBar = null;
20+
let retries = 0;
21+
while (!defaultSearchBar && retries < 10) {
22+
for (const el of document.querySelectorAll("*")) {
23+
if (el.querySelector('#local-search > button')) {
24+
defaultSearchBar = el.querySelector('#local-search > button');
25+
break;
26+
}
27+
}
28+
retries++;
29+
await new Promise((resolve) => setTimeout(resolve, 10));
30+
}
31+
32+
if (!defaultSearchBar) {
33+
return;
34+
}
35+
36+
defaultSearchBar = removeAllClickListeners(defaultSearchBar);
37+
38+
defaultSearchBar.onclick = () => {
39+
const event = new CustomEvent("trieve-open-with-text", {
40+
detail: { text: "" },
41+
});
42+
window.dispatchEvent(event);
43+
};
44+
};
45+
46+
window.addEventListener('load', function() {
47+
makeDefaultSearchTrieve();
48+
});
49+
50+
const originalPushState = history.pushState;
51+
history.pushState = function() {
52+
originalPushState.apply(this, arguments);
53+
makeDefaultSearchTrieve();
54+
};
55+
56+
57+
(async function () {
58+
"use strict";
59+
const link = document.createElement("link");
60+
link.rel = "stylesheet";
61+
link.href = "https://cdn.trieve.ai/beta/search-component/index.css";
62+
document.head.appendChild(link);
63+
64+
import("https://cdn.trieve.ai/beta/search-component/vanilla/index.js").then(
65+
async (module) => {
66+
const { renderToDiv } = module;
67+
const root = document.createElement("div");
68+
root.classList.add("trigger");
69+
document.body.appendChild(root);
70+
const colorScheme = document.documentElement?.classList?.contains("dark")
71+
? "dark"
72+
: null;
73+
74+
renderToDiv(root, {
75+
apiKey: "tr-4ge266qRg6AzfMAyWyqqUjmG3VC1CYYM",
76+
datasetId: "cae68afa-93e1-4fb2-9945-693e65906409",
77+
baseUrl: "https://api.trieve.ai",
78+
type: "docs",
79+
analytics: true,
80+
theme: colorScheme === "dark" ? "dark" : null,
81+
brandLogoImgSrcUrl: "https://coolify.io/docs/coolify-logo-transparent.png",
82+
brandName: "Coolify",
83+
brandColor: "#9664f3",
84+
placeholder: "How can I help?",
85+
defaultSearchQueries: ["Backups", "Postgresql", "Private NPM registry"],
86+
defaultAiQuestions: ["How to fix expired GitHub personal access token (PAT)?", "My Raspberry Pi is crashing", "How to use Docker Compose?"],
87+
defaultSearchMode: "search",
88+
showFloatingButton: "true",
89+
cssRelease: "none",
90+
hideOpenButton: true,
91+
});
92+
},
93+
(error) => {
94+
console.error("Failed to load module:", error);
95+
}
96+
);
97+
})();

0 commit comments

Comments
 (0)