From d5b9655063693be76d2205453af05f73ab98b8e8 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Fri, 9 Aug 2024 11:31:17 +0200 Subject: [PATCH] add further usage examples --- examples/full/.testRun.ts | 10 ++++++++++ examples/full/pages/index/+Page.tsx | 7 ++++++- examples/full/pages/star-wars/index/+data.ts | 13 +++++++++++++ examples/full/pages/star-wars/index/+description.ts | 9 --------- examples/full/pages/star-wars/index/+title.ts | 9 --------- 5 files changed, 29 insertions(+), 19 deletions(-) delete mode 100644 examples/full/pages/star-wars/index/+description.ts delete mode 100644 examples/full/pages/star-wars/index/+title.ts diff --git a/examples/full/.testRun.ts b/examples/full/.testRun.ts index 31b2d69..72f5ec7 100644 --- a/examples/full/.testRun.ts +++ b/examples/full/.testRun.ts @@ -16,6 +16,7 @@ function testRun(cmd: `pnpm run ${"dev" | "preview"}`) { title: "My Vike + Solid App", text: "Rendered to HTML.", counter: true, + image: true, }); testUrl({ @@ -23,6 +24,7 @@ function testRun(cmd: `pnpm run ${"dev" | "preview"}`) { title: "6 Star Wars Movies", description: "All the 6 movies from the Star Wars franchise", text: "A New Hope", + image: true, }); testUrl({ @@ -94,6 +96,7 @@ function testUrl({ text, counter, noSSR, + image, }: { url: string; title: string; @@ -101,6 +104,7 @@ function testUrl({ text: string; counter?: true; noSSR?: true; + image?: true; }) { test(url + " (HTML)", async () => { const html = await fetchHtml(url); @@ -113,6 +117,12 @@ function testUrl({ if (!description) description = "Demo showcasing Vike + Solid"; expect(html).toMatch(partRegex``); + + if (image) { + expect(html).toMatch(partRegex``); + } else { + expect(html).not.toContain("og:image"); + } }); test(url + " (Hydration)", async () => { await page.goto(getServerUrl() + url); diff --git a/examples/full/pages/index/+Page.tsx b/examples/full/pages/index/+Page.tsx index da91dff..7232688 100644 --- a/examples/full/pages/index/+Page.tsx +++ b/examples/full/pages/index/+Page.tsx @@ -1,4 +1,8 @@ +export { Page }; + import { clientOnly } from "vike-solid/clientOnly"; +import { Config } from "vike-solid/Config"; +import image from "../../assets/logo-new.svg"; const ClientOnlyCounter = clientOnly(() => import("./Counter")); const ClientOnlyCounterSlow = clientOnly(async () => { @@ -8,9 +12,10 @@ const ClientOnlyCounterSlow = clientOnly(async () => { return import("./Counter"); }); -export default function Page() { +function Page() { return ( <> +

My Vike + Solid App

This page is: