@docubook/create 1.14.2 → 1.15.0
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 +1 -1
- package/src/dist/app/layout.tsx +1 -0
- package/src/dist/app/page.tsx +1 -1
- package/src/dist/components/DocSearch.tsx +33 -0
- package/src/dist/components/search.tsx +24 -20
- package/src/dist/contents/docs/changelog/version-1/index.mdx +23 -0
- package/src/dist/package.json +5 -1
- package/src/dist/styles/algolia.css +156 -0
package/package.json
CHANGED
package/src/dist/app/layout.tsx
CHANGED
package/src/dist/app/page.tsx
CHANGED
|
@@ -25,7 +25,7 @@ export default function Home() {
|
|
|
25
25
|
)}
|
|
26
26
|
>
|
|
27
27
|
<AnimatedShinyText className="inline-flex items-center justify-center px-4 py-1 transition ease-out hover:text-neutral-100 hover:duration-300 hover:dark:text-neutral-200">
|
|
28
|
-
<span>🚀 New Version - Release v1.
|
|
28
|
+
<span>🚀 New Version - Release v1.15.0</span>
|
|
29
29
|
<ArrowRightIcon className="ml-1 size-3 transition-transform duration-300 ease-in-out group-hover:translate-x-0.5" />
|
|
30
30
|
</AnimatedShinyText>
|
|
31
31
|
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { DocSearch } from "@docsearch/react";
|
|
5
|
+
import "@docsearch/css";
|
|
6
|
+
|
|
7
|
+
export default function DocSearchComponent() {
|
|
8
|
+
const appId = process.env.NEXT_PUBLIC_ALGOLIA_DOCSEARCH_APP_ID;
|
|
9
|
+
const apiKey = process.env.NEXT_PUBLIC_ALGOLIA_DOCSEARCH_API_KEY;
|
|
10
|
+
const indexName = process.env.NEXT_PUBLIC_ALGOLIA_DOCSEARCH_INDEX_NAME;
|
|
11
|
+
|
|
12
|
+
if (!appId || !apiKey || !indexName) {
|
|
13
|
+
console.error(
|
|
14
|
+
"DocSearch credentials are not set in the environment variables."
|
|
15
|
+
);
|
|
16
|
+
return (
|
|
17
|
+
<button className="text-sm text-muted-foreground" disabled>
|
|
18
|
+
Search... (misconfigured)
|
|
19
|
+
</button>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className="docsearch">
|
|
25
|
+
<DocSearch
|
|
26
|
+
appId={appId}
|
|
27
|
+
apiKey={apiKey}
|
|
28
|
+
indexName={indexName}
|
|
29
|
+
placeholder="Type something to search..."
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -4,11 +4,12 @@ import { useState, useEffect } from "react";
|
|
|
4
4
|
import { Dialog } from "@/components/ui/dialog";
|
|
5
5
|
import { SearchTrigger } from "@/components/SearchTrigger";
|
|
6
6
|
import { SearchModal } from "@/components/SearchModal";
|
|
7
|
+
import DocSearchComponent from "@/components/DocSearch";
|
|
8
|
+
import { DialogTrigger } from "@radix-ui/react-dialog";
|
|
7
9
|
|
|
8
|
-
// Define props for the Search component
|
|
9
10
|
interface SearchProps {
|
|
10
11
|
/**
|
|
11
|
-
* Specify
|
|
12
|
+
* Specify which search engine to use.
|
|
12
13
|
* @default 'default'
|
|
13
14
|
*/
|
|
14
15
|
type?: "default" | "algolia";
|
|
@@ -17,33 +18,36 @@ interface SearchProps {
|
|
|
17
18
|
export default function Search({ type = "default" }: SearchProps) {
|
|
18
19
|
const [isOpen, setIsOpen] = useState(false);
|
|
19
20
|
|
|
20
|
-
//
|
|
21
|
+
// The useEffect below is ONLY for the 'default' type, which is correct.
|
|
22
|
+
// DocSearch handles its own keyboard shortcut.
|
|
21
23
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
event.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (type === 'default') {
|
|
25
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
26
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
setIsOpen((open) => !open);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
33
|
+
return () => {
|
|
34
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}, [type]);
|
|
34
38
|
|
|
35
|
-
// Here you can add logic for different search types if needed in the future
|
|
36
39
|
if (type === "algolia") {
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
// For now, we will fall back to the default search implementation
|
|
40
|
+
// Just render the component without passing any state props
|
|
41
|
+
return <DocSearchComponent />;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
//
|
|
44
|
+
// Logic for 'default' search
|
|
43
45
|
return (
|
|
44
46
|
<div>
|
|
45
47
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
|
46
|
-
<
|
|
48
|
+
<DialogTrigger asChild>
|
|
49
|
+
<SearchTrigger />
|
|
50
|
+
</DialogTrigger>
|
|
47
51
|
<SearchModal isOpen={isOpen} setIsOpen={setIsOpen} />
|
|
48
52
|
</Dialog>
|
|
49
53
|
</div>
|
|
@@ -8,6 +8,29 @@ date: 02-08-2025
|
|
|
8
8
|
This changelog contains a list of all the changes made to the DocuBook template. It will be updated with each new release and will include information about new features, bug fixes, and other improvements.
|
|
9
9
|
</Note>
|
|
10
10
|
|
|
11
|
+
<div className="sr-only">
|
|
12
|
+
### v 1.15.0
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<Release version="1.15.0" date="2025-08-06" title="Algolia DocSearch for better search result">
|
|
16
|
+
<Changes type="added">
|
|
17
|
+
- new DocSearch.tsx components
|
|
18
|
+
- add props type algolia
|
|
19
|
+
- add searchprops
|
|
20
|
+
- add algolia.css
|
|
21
|
+
</Changes>
|
|
22
|
+
</Release>
|
|
23
|
+
|
|
24
|
+
<Note type="warning" title="environment">
|
|
25
|
+
To use Algolia DocSearch, you need to configure the following environment variables:
|
|
26
|
+
|
|
27
|
+
```plaintext
|
|
28
|
+
NEXT_PUBLIC_ALGOLIA_DOCSEARCH_APP_ID="your_app_id"
|
|
29
|
+
NEXT_PUBLIC_ALGOLIA_DOCSEARCH_API_KEY="your_api_key"
|
|
30
|
+
NEXT_PUBLIC_ALGOLIA_DOCSEARCH_INDEX_NAME="your_index_name"
|
|
31
|
+
```
|
|
32
|
+
</Note>
|
|
33
|
+
|
|
11
34
|
<div className="sr-only">
|
|
12
35
|
### v 1.14.2
|
|
13
36
|
</div>
|
package/src/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docubook",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "next dev",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"lint": "next lint"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"@docsearch/css": "3",
|
|
13
|
+
"@docsearch/react": "^3.9.0",
|
|
12
14
|
"@radix-ui/react-accordion": "^1.2.0",
|
|
13
15
|
"@radix-ui/react-avatar": "^1.1.0",
|
|
14
16
|
"@radix-ui/react-collapsible": "^1.1.0",
|
|
@@ -21,12 +23,14 @@
|
|
|
21
23
|
"@radix-ui/react-tabs": "^1.1.0",
|
|
22
24
|
"@radix-ui/react-toggle": "^1.1.2",
|
|
23
25
|
"@radix-ui/react-toggle-group": "^1.1.2",
|
|
26
|
+
"algoliasearch": "^5.35.0",
|
|
24
27
|
"class-variance-authority": "^0.7.0",
|
|
25
28
|
"clsx": "^2.1.1",
|
|
26
29
|
"cmdk": "1.0.0",
|
|
27
30
|
"framer-motion": "^12.4.1",
|
|
28
31
|
"geist": "^1.3.1",
|
|
29
32
|
"gray-matter": "^4.0.3",
|
|
33
|
+
"install": "^0.13.0",
|
|
30
34
|
"lucide-react": "^0.511.0",
|
|
31
35
|
"next": "^14.2.6",
|
|
32
36
|
"next-mdx-remote": "^5.0.0",
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
================================================================================
|
|
3
|
+
DocSearch Component Styling (Themed Version)
|
|
4
|
+
- This version uses the CSS variables defined in :root and .dark
|
|
5
|
+
to automatically adapt to your site's light and dark themes.
|
|
6
|
+
================================================================================
|
|
7
|
+
*/
|
|
8
|
+
.docsearch {
|
|
9
|
+
/* Map theme variables to DocSearch's internal variables */
|
|
10
|
+
--docsearch-primary-color: hsl(var(--primary));
|
|
11
|
+
--docsearch-text-color: hsl(var(--foreground));
|
|
12
|
+
--docsearch-container-background: hsla(var(--background) / 0.8); /* Use theme background with transparency */
|
|
13
|
+
--docsearch-modal-background: hsl(var(--card)); /* Modals should use card color */
|
|
14
|
+
--docsearch-modal-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
15
|
+
--docsearch-searchbox-background: hsl(var(--secondary));
|
|
16
|
+
--docsearch-searchbox-focus-background: hsl(var(--secondary));
|
|
17
|
+
--docsearch-hit-color: hsl(var(--foreground));
|
|
18
|
+
--docsearch-hit-background: hsl(var(--card));
|
|
19
|
+
--docsearch-hit-shadow: none;
|
|
20
|
+
--docsearch-hit-active-color: hsl(var(--primary-foreground));
|
|
21
|
+
--docsearch-selected-background: hsl(var(--secondary)); /* Use secondary for selection */
|
|
22
|
+
--docsearch-footer-background: hsl(var(--card));
|
|
23
|
+
--docsearch-footer-shadow: inset 0 1px 0 0 hsl(var(--border));
|
|
24
|
+
--docsearch-key-gradient: transparent;
|
|
25
|
+
--docsearch-key-shadow: none;
|
|
26
|
+
--docsearch-muted-color: hsl(var(--muted-foreground)); /* Use muted for less important text */
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* =====================================
|
|
31
|
+
* 1. Initial Search Button Styling
|
|
32
|
+
* =====================================
|
|
33
|
+
*/
|
|
34
|
+
.docsearch .DocSearch-Button {
|
|
35
|
+
background-color: hsl(var(--secondary)); /* Use secondary for the button background */
|
|
36
|
+
border: 1px solid hsl(var(--border)); /* Use the standard border color */
|
|
37
|
+
border-radius: 9999px; /* Pill shape */
|
|
38
|
+
width: 160px; /* Lebar default untuk desktop */
|
|
39
|
+
height: 40px;
|
|
40
|
+
color: hsl(var(--muted-foreground)); /* Use muted text color for the placeholder */
|
|
41
|
+
transition: width 0.3s ease; /* Transisi untuk perubahan lebar */
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.docsearch .DocSearch-Button:hover {
|
|
45
|
+
border-color: var(--docsearch-primary-color);
|
|
46
|
+
box-shadow: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Magnifying glass icon */
|
|
50
|
+
.docsearch .DocSearch-Search-Icon {
|
|
51
|
+
color: hsl(var(--muted-foreground));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* The 'Search' placeholder text */
|
|
55
|
+
.docsearch .DocSearch-Button-Placeholder {
|
|
56
|
+
font-style: normal;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Styling for the '⌘K' keys */
|
|
60
|
+
.docsearch .DocSearch-Button-Key {
|
|
61
|
+
background: hsl(var(--primary)); /* Use primary color for the key background */
|
|
62
|
+
border-radius: 6px;
|
|
63
|
+
color: hsl(var(--primary-foreground)); /* Use primary-foreground for the key text */
|
|
64
|
+
font-size: 14px;
|
|
65
|
+
font-weight: 500;
|
|
66
|
+
height: 24px;
|
|
67
|
+
padding: 0 6px;
|
|
68
|
+
border: none;
|
|
69
|
+
box-shadow: none;
|
|
70
|
+
top: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
* =====================================
|
|
76
|
+
* 2. Modal and Results Styling
|
|
77
|
+
* =====================================
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/* Main modal window */
|
|
81
|
+
.docsearch .DocSearch-Modal {
|
|
82
|
+
backdrop-filter: blur(8px);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.docsearch .DocSearch-Container {
|
|
86
|
+
box-shadow: var(--docsearch-modal-shadow);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Search input form */
|
|
90
|
+
.docsearch .DocSearch-Form {
|
|
91
|
+
border: 1px solid hsl(var(--border));
|
|
92
|
+
box-shadow: none;
|
|
93
|
+
background-color: transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* The 'Return' and 'Esc' hints */
|
|
97
|
+
.docsearch .DocSearch-Reset-Icon,
|
|
98
|
+
.docsearch .DocSearch-Cancel {
|
|
99
|
+
color: hsl(var(--muted-foreground));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Style for each search result item */
|
|
103
|
+
.docsearch .DocSearch-Hit a {
|
|
104
|
+
border-radius: 4px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Selected search result */
|
|
108
|
+
.docsearch .DocSearch-Hit[aria-selected="true"] a {
|
|
109
|
+
background: var(--docsearch-selected-background); /* Highlight color for selected item */
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* Hide category headers if not needed */
|
|
113
|
+
.docsearch .DocSearch-Hit-source {
|
|
114
|
+
display: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Icon next to each result title */
|
|
118
|
+
.docsearch .DocSearch-Hit-icon {
|
|
119
|
+
color: hsl(var(--muted-foreground));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Footer instructions ('to navigate', 'to select', etc.) */
|
|
123
|
+
.docsearch .DocSearch-Footer {
|
|
124
|
+
border-top: 1px solid hsl(var(--border));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.docsearch .DocSearch-Footer--commands kbd {
|
|
128
|
+
background: hsl(var(--muted)); /* Use muted for the background of keyboard hints */
|
|
129
|
+
border: 1px solid hsl(var(--border));
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
color: hsl(var(--muted-foreground));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/*
|
|
135
|
+
* =====================================
|
|
136
|
+
* 3. Responsive Styling (Mobile)
|
|
137
|
+
* =====================================
|
|
138
|
+
*/
|
|
139
|
+
@media (max-width: 768px) {
|
|
140
|
+
/* Aturan ini akan aktif pada layar 768px ke bawah */
|
|
141
|
+
|
|
142
|
+
.docsearch .DocSearch-Button {
|
|
143
|
+
width: 40px; /* Mengubah lebar tombol menjadi seukuran ikon */
|
|
144
|
+
height: 40px; /* Memastikan tinggi tetap sama */
|
|
145
|
+
padding: 0; /* Menghapus padding agar ikon bisa di tengah */
|
|
146
|
+
justify-content: center; /* Memusatkan ikon di dalam tombol */
|
|
147
|
+
background: none;
|
|
148
|
+
border: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* Menyembunyikan teks "Search..." dan shortcut keyboard */
|
|
152
|
+
.docsearch .DocSearch-Button-Placeholder,
|
|
153
|
+
.docsearch .DocSearch-Button-Key {
|
|
154
|
+
display: none;
|
|
155
|
+
}
|
|
156
|
+
}
|