From 2a37a7d1914965f0a0eff09a00c3c1321008275c Mon Sep 17 00:00:00 2001 From: Drew Harris Date: Tue, 7 Jan 2025 18:04:16 -0600 Subject: [PATCH] feat: autofill favicon public page icon from scrape settings --- .../src/hooks/usePublicPageSettings.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontends/dashboard/src/hooks/usePublicPageSettings.tsx b/frontends/dashboard/src/hooks/usePublicPageSettings.tsx index 90c72e2af..f33dbab0c 100644 --- a/frontends/dashboard/src/hooks/usePublicPageSettings.tsx +++ b/frontends/dashboard/src/hooks/usePublicPageSettings.tsx @@ -79,6 +79,23 @@ export const { use: usePublicPage, provider: PublicPageProvider } = } }); + // If the dataset has a url in crawl_options, automatically fill out a favicon.ico. + createEffect(() => { + if ( + crawlSettingsQuery.data?.site_url && + !extraParams.brandLogoImgSrcUrl + ) { + const stripTrailingSlash = (str: string) => { + return str.endsWith("/") ? str.slice(0, -1) : str; + }; + + setExtraParams( + "brandLogoImgSrcUrl", + stripTrailingSlash(crawlSettingsQuery.data.site_url) + "/favicon.ico", + ); + } + }); + // manually set the array for rolemessages to simplify logic // context blocks until it's set createEffect(() => {