docs: fix regression in navigation (#2047)

This commit is contained in:
Marvin Hagemeister
2023-11-16 10:38:13 +01:00
committed by GitHub
parent 93c17b7184
commit 7578e50ee3
4 changed files with 48 additions and 36 deletions
+12
View File
@@ -0,0 +1,12 @@
import { waitForText, withPageName } from "$fresh/tests/test_utils.ts";
Deno.test("www - docs navigation", async () => {
await withPageName("./www/main.ts", async (page, address) => {
await page.goto(`${address}`, { waitUntil: "networkidle2" });
await page.click(`a[href="/docs"]`);
await waitForText(page, "h1", "Introduction");
await page.click(`a[href="/docs/getting-started/create-a-project"]`);
await waitForText(page, "h1", "Create a project");
});
});
+1 -2
View File
@@ -8,7 +8,6 @@ import VersionSelect from "../islands/VersionSelect.tsx";
import { type VersionLink } from "../routes/docs/[...slug].tsx"; import { type VersionLink } from "../routes/docs/[...slug].tsx";
import { Logo } from "$fresh/www/components/Header.tsx"; import { Logo } from "$fresh/www/components/Header.tsx";
import DocsTitle from "$fresh/www/components/DocsTitle.tsx"; import DocsTitle from "$fresh/www/components/DocsTitle.tsx";
import docsearch from "https://esm.sh/@docsearch/js@3?target=es2020";
export default function DocsSidebar( export default function DocsSidebar(
props: { props: {
@@ -28,7 +27,7 @@ export default function DocsSidebar(
</div> </div>
<hr /> <hr />
</div> </div>
<SearchButton class="mr-4 sm:mr-0" docsearch={docsearch} /> <SearchButton class="mr-4 sm:mr-0" />
<div class="mb-4"> <div class="mb-4">
<VersionSelect <VersionSelect
selectedVersion={props.selectedVersion} selectedVersion={props.selectedVersion}
+32 -32
View File
@@ -2,44 +2,44 @@
// This file SHOULD be checked into source version control. // This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`. // This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/_404.tsx"; import * as $_404 from "./routes/_404.tsx";
import * as $1 from "./routes/_500.tsx"; import * as $_500 from "./routes/_500.tsx";
import * as $2 from "./routes/_middleware.ts"; import * as $_middleware from "./routes/_middleware.ts";
import * as $3 from "./routes/components.tsx"; import * as $components from "./routes/components.tsx";
import * as $4 from "./routes/docs/[...slug].tsx"; import * as $docs_slug_ from "./routes/docs/[...slug].tsx";
import * as $5 from "./routes/docs/index.tsx"; import * as $docs_index from "./routes/docs/index.tsx";
import * as $6 from "./routes/index.tsx"; import * as $index from "./routes/index.tsx";
import * as $7 from "./routes/raw.ts"; import * as $raw from "./routes/raw.ts";
import * as $8 from "./routes/showcase.tsx"; import * as $showcase from "./routes/showcase.tsx";
import * as $9 from "./routes/update.tsx"; import * as $update from "./routes/update.tsx";
import * as $$0 from "./islands/ComponentGallery.tsx"; import * as $$ComponentGallery from "./islands/ComponentGallery.tsx";
import * as $$1 from "./islands/CopyArea.tsx"; import * as $$CopyArea from "./islands/CopyArea.tsx";
import * as $$2 from "./islands/Counter.tsx"; import * as $$Counter from "./islands/Counter.tsx";
import * as $$3 from "./islands/LemonDrop.tsx"; import * as $$LemonDrop from "./islands/LemonDrop.tsx";
import * as $$4 from "./islands/SearchButton.tsx"; import * as $$SearchButton from "./islands/SearchButton.tsx";
import * as $$5 from "./islands/VersionSelect.tsx"; import * as $$VersionSelect from "./islands/VersionSelect.tsx";
import { Manifest } from "$fresh/server.ts"; import { Manifest } from "$fresh/server.ts";
const manifest = { const manifest = {
routes: { routes: {
"./routes/_404.tsx": $0, "./routes/_404.tsx": $_404,
"./routes/_500.tsx": $1, "./routes/_500.tsx": $_500,
"./routes/_middleware.ts": $2, "./routes/_middleware.ts": $_middleware,
"./routes/components.tsx": $3, "./routes/components.tsx": $components,
"./routes/docs/[...slug].tsx": $4, "./routes/docs/[...slug].tsx": $docs_slug_,
"./routes/docs/index.tsx": $5, "./routes/docs/index.tsx": $docs_index,
"./routes/index.tsx": $6, "./routes/index.tsx": $index,
"./routes/raw.ts": $7, "./routes/raw.ts": $raw,
"./routes/showcase.tsx": $8, "./routes/showcase.tsx": $showcase,
"./routes/update.tsx": $9, "./routes/update.tsx": $update,
}, },
islands: { islands: {
"./islands/ComponentGallery.tsx": $$0, "./islands/ComponentGallery.tsx": $$ComponentGallery,
"./islands/CopyArea.tsx": $$1, "./islands/CopyArea.tsx": $$CopyArea,
"./islands/Counter.tsx": $$2, "./islands/Counter.tsx": $$Counter,
"./islands/LemonDrop.tsx": $$3, "./islands/LemonDrop.tsx": $$LemonDrop,
"./islands/SearchButton.tsx": $$4, "./islands/SearchButton.tsx": $$SearchButton,
"./islands/VersionSelect.tsx": $$5, "./islands/VersionSelect.tsx": $$VersionSelect,
}, },
baseUrl: import.meta.url, baseUrl: import.meta.url,
} satisfies Manifest; } satisfies Manifest;
+3 -2
View File
@@ -1,5 +1,6 @@
import { Head } from "$fresh/runtime.ts"; import { Head } from "$fresh/runtime.ts";
import { useEffect, useRef } from "preact/hooks"; import { useEffect, useRef } from "preact/hooks";
import docsearch from "https://esm.sh/@docsearch/js@3.5.2?target=es2020";
// Copied from algolia source code // Copied from algolia source code
type DocSearchProps = { type DocSearchProps = {
@@ -10,12 +11,12 @@ type DocSearchProps = {
}; };
export default function SearchButton( export default function SearchButton(
props: { docsearch: (args: DocSearchProps) => void; class?: string }, props: { docsearch?: (args: DocSearchProps) => void; class?: string },
) { ) {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
useEffect(() => { useEffect(() => {
if (ref.current) { if (ref.current) {
props.docsearch({ props.docsearch || docsearch({
appId: "CWUS37S0PK", appId: "CWUS37S0PK",
apiKey: "caa591b6dcb2c9308551361d954a728b", apiKey: "caa591b6dcb2c9308551361d954a728b",
indexName: "fresh", indexName: "fresh",