From 4c6f750e520904908cd9ad6b9b700176799324a0 Mon Sep 17 00:00:00 2001 From: Fraser Date: Mon, 10 Jul 2023 20:39:54 -0400 Subject: [PATCH] link to duckduckgo when url field empty --- web/src/pages/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/pages/index.tsx b/web/src/pages/index.tsx index edce828..143d0cf 100644 --- a/web/src/pages/index.tsx +++ b/web/src/pages/index.tsx @@ -72,9 +72,14 @@ const ShowCitation: React.FC<{citation: Citation, i: number}> = ({citation, i}) if (citation.date && citation.date !== "") c_str += " - " + citation.date; + // if we don't have a url, link to a duckduckgo search for the title instead + const url = citation.url && citation.url !== "" + ? citation.url + : `https://duckduckgo.com/?q=${encodeURIComponent(citation.title)}`; + return ( + href={url}> [{i + 1}]

{c_str}