Skip to content

Commit 698acb2

Browse files
authored
Add Pagefind to docs (#801)
* Add Pagefind to docs * Improve callout styles and allow to have no icon
1 parent bfe267c commit 698acb2

File tree

3 files changed

+94
-15
lines changed

3 files changed

+94
-15
lines changed

docs/pages/components/callout.mdx

+29
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type CalloutProps = {
1818
children: ReactNode;
1919
title?: string;
2020
className?: string;
21+
icon?: boolean;
2122
};
2223
```
2324

@@ -80,3 +81,31 @@ type CalloutProps = {
8081
This raises a warning to watch out for.
8182
</Callout>
8283
```
84+
85+
## Variations
86+
87+
Callouts can be customized by omitting the title or icon:
88+
89+
<Callout type="note">Without a title</Callout>
90+
91+
<Callout type="note" icon={false} title="Without an icon">
92+
You can hide the icon while keeping the title
93+
</Callout>
94+
95+
<Callout type="note" icon={false}>
96+
Or have neither title nor icon
97+
</Callout>
98+
99+
```tsx
100+
<Callout type="note">
101+
Without a title
102+
</Callout>
103+
104+
<Callout type="note" icon={false} title="Without an icon">
105+
You can hide the icon while keeping the title
106+
</Callout>
107+
108+
<Callout type="note" icon={false}>
109+
Or have neither title nor icon
110+
</Callout>
111+
```

docs/pages/configuration/search.md

+37-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,47 @@ title: Search
33
sidebar_icon: search-code
44
---
55

6-
It is possible to add search to a Zudoku powered site. It will appear in the top navigation and persist across all pages.
6+
Zudoku offers search functionality that enhances user experience by enabling content discovery across your site. When configured, a search bar will appear in the header, allowing users to quickly find relevant information on any page.
77

8-
## Configuration
8+
We currently support two search providers:
99

10-
At this time, only [Inkeep](https://inkeep.com/) is supported.
10+
- [Pagefind](https://pagefind.app/)
11+
- [Inkeep](https://inkeep.com/)
1112

12-
### Inkeep
13+
## Pagefind
1314

14-
To add search to your site you will need to copy some variables from your [Inkeep account setting](https://portal.inkeep.com/):
15+
[Pagefind](https://pagefind.app/) is a lightweight, static search library that can be used to add search to your Zudoku site without any external services.
16+
17+
:::caution{icon=""}
18+
19+
While functional for production use, the Pagefind integration is still work in progress and will be improved in future releases and become the default search provider.
20+
21+
:::
22+
23+
To enable pagefind search, configure the `search` option in your configuration:
24+
25+
```typescript
26+
{
27+
search: {
28+
type: "pagefind",
29+
// Optional: Maximum number of sub results per page
30+
maxSubResults: 3
31+
// Optional: Configure search result ranking (defaults shown below)
32+
ranking: {
33+
termFrequency: 0.8,
34+
pageLength: 0.6,
35+
termSimilarity: 1.2,
36+
termSaturation: 1.2,
37+
},
38+
}
39+
}
40+
```
41+
42+
For more information about how Pagefind's ranking system works and how to customize it for your content, see the [Pagefind ranking documentation](https://pagefind.app/docs/ranking/).
43+
44+
## Inkeep
45+
46+
To add Inkeep search to your site you will need to copy some variables from your [Inkeep account setting](https://portal.inkeep.com/):
1547

1648
- API Key
1749
- Integration ID

packages/zudoku/src/lib/ui/Callout.tsx

+28-10
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,49 @@ type CalloutProps = {
5656
title?: string;
5757
children: ReactNode;
5858
className?: string;
59+
icon?: boolean;
5960
};
6061

61-
export const Callout = ({ type, children, title, className }: CalloutProps) => {
62+
export const Callout = ({
63+
type,
64+
children,
65+
title,
66+
className,
67+
icon = true,
68+
}: CalloutProps) => {
6269
const { border, bg, iconColor, titleColor, textColor, Icon } =
6370
stylesMap[type];
6471

6572
return (
6673
<div
6774
className={cn(
68-
"not-prose grid grid-cols-[min-content_1fr] grid-rows-[fit-content_1fr] gap-x-4 gap-y-2 text-md rounded-md border p-4",
75+
"not-prose rounded-md border p-4 text-md my-2",
76+
icon &&
77+
"grid grid-cols-[min-content_1fr] items-baseline grid-rows-[fit-content_1fr] gap-x-4 gap-y-2",
78+
!icon && title && "flex flex-col gap-2",
6979
"[&_a]:underline [&_a]:decoration-current [&_a]:decoration-from-font [&_a]:underline-offset-4 hover:[&_a]:decoration-1",
70-
"[&_code]:!bg-gray-50 [&_code]:dark:!bg-gray-800 [&_code]:!border-none my-2",
71-
title && "items-center",
80+
"[&_code]:!bg-gray-50 [&_code]:dark:!bg-gray-800 [&_code]:!border-none",
81+
icon && title && "items-center",
7282
border,
7383
bg,
7484
className,
7585
)}
7686
>
77-
<Icon
78-
className={cn(!title && "translate-y-px", iconColor)}
79-
size={20}
80-
aria-hidden="true"
81-
/>
87+
{icon && (
88+
<Icon
89+
className={cn(!title ? "translate-y-1" : "align-middle", iconColor)}
90+
size={20}
91+
aria-hidden="true"
92+
/>
93+
)}
8294
{title && <h3 className={cn("font-medium", titleColor)}>{title}</h3>}
83-
<div className={cn("col-start-2", !title && "row-start-1", textColor)}>
95+
<div
96+
className={cn(
97+
icon && "col-start-2",
98+
!title && icon && "row-start-1",
99+
textColor,
100+
)}
101+
>
84102
{children}
85103
</div>
86104
</div>

0 commit comments

Comments
 (0)