Skip to content

Commit 6490469

Browse files
inkeep script update (#25)
* update search ids * update tag id info --------- Co-authored-by: chdeskur <chdeskur@gmail.com>
1 parent 41de661 commit 6490469

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

fern/assets/inkeep.js

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const searchButtonContainerIds = [
2-
"fern-search-bar",
32
"fern-search-button",
3+
"fern-search-bar"
44
];
55

66
// Define the base settings
77
const inkeepSettings = {
8-
isOpen: true,
98
baseSettings: {
109
apiKey: "a58574ddc0e41c75990d1c0e890ad3c8725dc9e7c8ee3d3e",
1110
integrationId: "clthv1rgg000sdjil26l2vg03",
@@ -34,26 +33,6 @@ const inkeepSettings = {
3433
}
3534
};
3635

37-
// Function to initialize search containers
38-
function initializeSearchContainers() {
39-
// Clone and replace search buttons to remove existing listeners
40-
// Only process elements that exist
41-
const clonedSearchButtonContainers = searchButtonContainerIds
42-
.map((id) => {
43-
const originalElement = document.getElementById(id);
44-
if (!originalElement) {
45-
console.log(`Search container ${id} not found, skipping...`);
46-
return null;
47-
}
48-
const clonedElement = originalElement.cloneNode(true);
49-
originalElement.parentNode.replaceChild(clonedElement, originalElement);
50-
return clonedElement;
51-
})
52-
.filter(Boolean); // Remove null entries
53-
54-
return clonedSearchButtonContainers;
55-
}
56-
5736
// Function to initialize Inkeep
5837
function initializeInkeep() {
5938
// Color mode sync settings
@@ -88,13 +67,23 @@ function initializeInkeep() {
8867
},
8968
},
9069
});
91-
92-
// Get search containers after DOM is ready
93-
const clonedSearchButtonContainers = initializeSearchContainers();
70+
71+
const clonedSearchButtonContainers = searchButtonContainerIds
72+
.map((id) => {
73+
const originalElement = document.getElementById(id);
74+
if (!originalElement) {
75+
console.log(`Search container ${id} not found, skipping...`);
76+
return null;
77+
}
78+
originalElement.disabled = false;
79+
return originalElement
80+
}).filter(Boolean);
9481

9582
// Add click listeners to search buttons
9683
clonedSearchButtonContainers.forEach((trigger) => {
84+
console.log("adding trigger")
9785
trigger.addEventListener("click", function () {
86+
console.log("clicked")
9887
inkeepSearchModal.render({
9988
isOpen: true,
10089
});
@@ -106,7 +95,6 @@ function initializeInkeep() {
10695
"keydown",
10796
(event) => {
10897
if (
109-
(event.metaKey || event.ctrlKey) &&
11098
(event.key === "/")
11199
) {
112100
event.stopPropagation();

0 commit comments

Comments
 (0)