diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2dd4581..87c9afa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: run: deno check --remote init.ts - name: Type check website - run: deno check --remote main.ts dev.ts + run: deno check main.ts dev.ts working-directory: www/ - name: Type check examples/counter diff --git a/.github/workflows/www.yml b/.github/workflows/www.yml index cb649ebd..1709666a 100644 --- a/.github/workflows/www.yml +++ b/.github/workflows/www.yml @@ -28,5 +28,5 @@ jobs: working-directory: www/ - name: Type check website - run: deno check --remote main.ts dev.ts + run: deno check main.ts dev.ts working-directory: www/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..941fcf1c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +deno.lock \ No newline at end of file diff --git a/www/components/DocsSidebar.tsx b/www/components/DocsSidebar.tsx index 659b5e0d..8bff7e54 100644 --- a/www/components/DocsSidebar.tsx +++ b/www/components/DocsSidebar.tsx @@ -1,16 +1,52 @@ +import { Head } from "$fresh/runtime.ts"; import { CATEGORIES, TableOfContentsCategory, TableOfContentsCategoryEntry, } from "../data/docs.ts"; +import SearchButton from "../islands/SearchButton.tsx"; -export default function DocsSidebar(props: { path: string }) { +export default function DocsSidebar(props: { path: string; mobile?: boolean }) { + const id = String(Math.random()).replaceAll(".", ""); return ( -
    - {CATEGORIES.map((category) => ( - - ))} -
+ <> + {props.mobile + ? ( + + ) + : } + +
    + {CATEGORIES.map((category) => ( + + ))} +
+ ); } diff --git a/www/fresh.gen.ts b/www/fresh.gen.ts index 375947a9..55a917e1 100644 --- a/www/fresh.gen.ts +++ b/www/fresh.gen.ts @@ -16,6 +16,7 @@ import * as $$0 from "./islands/ComponentGallery.tsx"; import * as $$1 from "./islands/CopyArea.tsx"; import * as $$2 from "./islands/Counter.tsx"; import * as $$3 from "./islands/LemonDrop.tsx"; +import * as $$4 from "./islands/SearchButton.tsx"; const manifest = { routes: { @@ -34,6 +35,7 @@ const manifest = { "./islands/CopyArea.tsx": $$1, "./islands/Counter.tsx": $$2, "./islands/LemonDrop.tsx": $$3, + "./islands/SearchButton.tsx": $$4, }, baseUrl: import.meta.url, config, diff --git a/www/islands/SearchButton.tsx b/www/islands/SearchButton.tsx new file mode 100644 index 00000000..71a3cee9 --- /dev/null +++ b/www/islands/SearchButton.tsx @@ -0,0 +1,28 @@ +import { Head } from "$fresh/runtime.ts"; +import { useEffect, useRef } from "preact/hooks"; +import docsearch from "https://esm.sh/@docsearch/js@3"; + +export default function SearchButton() { + const ref = useRef(null); + useEffect(() => { + if (ref.current) { + docsearch({ + appId: "CWUS37S0PK", + apiKey: "caa591b6dcb2c9308551361d954a728b", + indexName: "fresh", + container: ref.current, + }); + } + }, [ref.current]); + return ( + <> + + + +
+ + ); +} diff --git a/www/routes/docs/[...slug].tsx b/www/routes/docs/[...slug].tsx index a837e090..6ffd09d6 100644 --- a/www/routes/docs/[...slug].tsx +++ b/www/routes/docs/[...slug].tsx @@ -128,8 +128,8 @@ function MobileSidebar(props: { path: string }) {
-