Skip to content

Commit

Permalink
link to duckduckgo when url field empty
Browse files Browse the repository at this point in the history
  • Loading branch information
FraserLee committed Jul 11, 2023
1 parent 494e533 commit 4c6f750
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<A className={Colours[i % Colours.length] + " border-2 flex items-center rounded my-2 text-sm no-underline w-fit"}
href={citation.url}>
href={url}>
<span className="mx-1"> [{i + 1}] </span>
<p className="mx-1 my-0"> {c_str} </p>
</A>
Expand Down

0 comments on commit 4c6f750

Please sign in to comment.