Skip to content

Commit 722a020

Browse files
committed
-
1 parent 4c06577 commit 722a020

File tree

11 files changed

+705
-15
lines changed

11 files changed

+705
-15
lines changed

api/src/bundler/getPlugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function getPlugins(config: OutputConfig) {
2323
if (config?.experimentalMath) {
2424
//@ts-ignore
2525
remarkPlugins.push(remarkMath);
26-
rehypePlugins.push(rehypeKatex);
26+
// rehypePlugins.push(rehypeKatex);
2727
}
2828
return { remarkPlugins, rehypePlugins };
2929
}

website-v3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"devDependencies": {
3131
"@astrojs/react": "^1.2.2",
32-
"@astrojs/vercel": "^2.3.5",
32+
"@astrojs/vercel": "2.3.4",
3333
"@tailwindcss/typography": "^0.5.8",
3434
"@types/classnames": "^2.3.1",
3535
"@types/color": "^3.0.3",

website-v3/src/components/Markdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Markdown: React.FC = () => {
1111
const MDX = getMDXComponent(code);
1212

1313
return (
14-
<main className="prose prose-slate dark:prose-invert prose-p:leading-loose prose-a:text-white prose-a:font-bold prose-a:underline-offset-[5px] prose-a:decoration-docs-theme prose-a:decoration-2 hover:prose-a:decoration-4 prose-headings:mb-[1rem] max-w-none">
14+
<main className="prose prose-slate dark:prose-invert prose-p:leading-loose dark:prose-a:text-white prose-a:font-bold prose-a:underline-offset-[5px] prose-a:decoration-docs-theme prose-a:decoration-2 hover:prose-a:decoration-4 prose-headings:mb-[1rem] max-w-none">
1515
<MDX
1616
components={{
1717
a: props => <Link {...props} href={props.href || '/'} />,

website-v3/src/components/Search.astro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
import { MagnifyingGlassIcon } from './icons';
3+
24
type Props = {
35
appId: string;
46
apiKey: string;
@@ -11,15 +13,34 @@ const { appId, apiKey, indexName } = Astro.props;
1113
---
1214

1315
<div data-docsearch data-appId={appId} data-apiKey={apiKey} data-indexName={indexName}></div>
16+
<button
17+
data-docsearch-override
18+
class="w-full bg-gradient-to-b from-gray-100 to-gray-100 dark:from-zinc-800/80 dark:to-zinc-800/40 flex items-center rounded px-4 py-2 border dark:border-zinc-800 hover:border-zinc-700/30 dark:hover:border-zinc-700/50 gap-2 text-sm text-gray-500 dark:text-white/70 dark:hover:text-white/90 transition"
19+
>
20+
<span class="w-4 h-4"><MagnifyingGlassIcon /></span>
21+
<span>Search...</span>
22+
<span class="flex-1 flex items-center justify-end font-semibold opacity-50">⌘K</span>
23+
</button>
24+
<style is:global></style>
1425
<script>
1526
import docsearch from '@docsearch/js';
1627

1728
const element = document.querySelector('div[data-docsearch]') as HTMLDivElement;
29+
const override = document.querySelector('button[data-docsearch-override]') as HTMLButtonElement;
1830

1931
docsearch({
2032
container: element,
2133
appId: element.dataset.appid!,
2234
indexName: element.dataset.indexname!,
2335
apiKey: element.dataset.apikey!,
2436
});
37+
38+
// Once triggered, get the native docsearch button
39+
const button = element.querySelector('button.DocSearch') as HTMLButtonElement;
40+
41+
// Hide it
42+
button.style.display = 'none';
43+
44+
// Then attach our own button to the native one
45+
override.addEventListener('click', () => button.click());
2546
</script>

website-v3/src/components/Theme.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ const dark = color.darken(0.2).hex().toString();
2828
root.style.setProperty('--theme-color', base);
2929
root.style.setProperty('--theme-color-dark', light);
3030
root.style.setProperty('--theme-color-light', dark);
31+
root.style.setProperty('--docsearch-primary-color', base);
3132
</script>

website-v3/src/components/icons.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const MagnifyingGlassIcon = () => (
2+
<svg
3+
xmlns="http://www.w3.org/2000/svg"
4+
fill="none"
5+
viewBox="0 0 24 24"
6+
strokeWidth={1.5}
7+
stroke="currentColor"
8+
>
9+
<path
10+
strokeLinecap="round"
11+
strokeLinejoin="round"
12+
d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
13+
/>
14+
</svg>
15+
);

website-v3/src/components/mdx/Image.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
77

88
const Image: React.FC<ImageProps> = props => {
99
const src = getImagePath(props.src ?? '');
10+
const { width, height, ...other } = props;
1011

1112
return (
12-
<img
13-
{...props}
14-
src={src}
15-
loading="lazy"
16-
style={{
17-
width: props.width ? parseInt(props.width.toString()) : 'inherit',
18-
height: props.height ? parseInt(props.height.toString()) : 'inherit',
19-
}}
20-
/>
13+
<figure>
14+
<img
15+
{...other}
16+
src={src}
17+
loading="lazy"
18+
className="mx-auto"
19+
style={{
20+
width: width ? parseInt(width.toString()) : 'inherit',
21+
height: height ? parseInt(height.toString()) : 'inherit',
22+
}}
23+
/>
24+
</figure>
2125
);
2226
};
2327

website-v3/src/layouts/Header.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const logoDark = getImagePath(config.logoDark);
1111
// TODO preview mode
1212
---
1313

14-
<header class="sticky top-0 border-b border-slate-800/80 bg:white z-10 backdrop-blur">
14+
<header class="sticky top-0 border-b dark:border-slate-800/80 bg:white z-10 backdrop-blur">
1515
<div class="absolute inset-0 z-0 dark:bg-zinc-900/90 dark:text-white"></div>
1616
<div class="max-w-8xl mx-auto relative z-10">
1717
<div class="h-16 px-4 lg:px-8 mx-4 lg:mx-0 flex items-center">
@@ -33,7 +33,11 @@ const logoDark = getImagePath(config.logoDark);
3333
}
3434
</Link>
3535
</div>
36-
<div>
36+
<div
37+
class:list={{
38+
'lg:w-64 xl:w-80': !!config.docsearch,
39+
}}
40+
>
3741
{!!config.docsearch && <Search {...config.docsearch} />}
3842
</div>
3943
<div class="flex-1 flex items-center justify-end">Menu</div>

website-v3/src/layouts/Root.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const theme = Astro.cookies.get('theme').value;
6060
<script is:inline define:vars={{ theme }}>
6161
// Only check users preference if they haven't already set a theme
6262
if (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
63-
document.documentElement.classList.add('dark');
63+
document.documentElement.setAttribute('data-theme', 'dark');
6464
}
6565
</script>
6666
<slot />

website-v3/tailwind.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @type {import('tailwindcss').Config} */
22
module.exports = {
33
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
4+
darkMode: ['class', '[data-theme="dark"]'],
45
theme: {
56
extend: {
67
maxWidth: {

0 commit comments

Comments
 (0)