From 441d9ac4cc70f339f3197645fc43f366d7b09f72 Mon Sep 17 00:00:00 2001 From: Korbs Date: Wed, 23 Oct 2024 16:48:08 -0400 Subject: [PATCH] Add sublinks, answer, images, and proxy images for now on --- source/src/pages/web.astro | 87 +++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 15 deletions(-) diff --git a/source/src/pages/web.astro b/source/src/pages/web.astro index 046a0f4..1f43527 100644 --- a/source/src/pages/web.astro +++ b/source/src/pages/web.astro @@ -4,22 +4,43 @@ import Search from "@layouts/Search.astro"; // Configuration import { - DEFAULT_API + DEFAULT_API, + DEFAULT_IMAGE_PROXY } from "@utils/GetConfig" // Components +import Answer from "@components/search/Answer.astro"; import RelatedSearches from "@components/search/RelatedSearches.astro"; import WebLink from "@components/search/WebLink.astro"; import WebLinkSkeleton from "@components/search/WebLinkSkeleton.astro"; +import { undefined } from "astro:schema"; // Fetch const QueryString = Astro.url.href.split("web?=").pop() // Get user's search query from URL const QueryText = `${QueryString}`.replaceAll("%20", " ") // Replace "%20" with a space const Query = await fetch(DEFAULT_API + "/api/v1/web?s=" + QueryString).then((response) => response.json()); // Response + +// Toggle Functions +if (Query.answer[0] === undefined) { + var ShowAnswer = false +} else { + var ShowAnswer = true +} +if (Query.related[0] === undefined) { + var ShowRelated = false +} else { + var ShowRelated = true +} +console.log(ShowRelated + '' + Query.related[0]) --- +
+ {Query.image.map((img) => ( + + ))} +
{Query.web.map((query) => ( + + {query.sublink.map((link) => + +

{link.title}

+

{link.url}

+
+ )} +
))}
- - {Query.related.map((related) => ( - {related} - ))} - - - - + {ShowAnswer ? + + : + null + } + {ShowRelated ? + + {Query.related.map((related) => ( + {related} + ))} + + + + + : + null + } JSON Response
@@ -83,4 +126,18 @@ const Query = await fetch(DEFAULT_API + "/api/v1/web?s=" + QueryString).then((re margin-bottom: 6px; margin-right: 6px; } + +.search-web-with-images { + display: grid; + gap: 12px 0px; + grid-template-columns: repeat( 4, minmax(100px, 1fr)); + margin-bottom: 12px; + img { + width: 182px; + height: 80px; + object-fit: cover; + border-radius: 6px; + border: 1px rgb(170,170,170) solid; + } +} \ No newline at end of file