Skip to content

Commit

Permalink
Merge pull request #101 from eye-on-surveillance/AI/urls
Browse files Browse the repository at this point in the history
AI/urls
  • Loading branch information
ayyubibrahimi authored Sep 28, 2023
2 parents 0279fbd + 1225360 commit 339c4a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/web/components/Citation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ interface CitationProps {
index: number;
}

const citationKeyMap: { [key: string]: string } = {
source_title: "Source Title",
source_name: "Source Name",
source_publish_date: "Source Publish Date",
source_url: "Source URL",
};

const Citation = ({ citation, index }: CitationProps) => {
const hasMetadata = Object.values(citation).some(
(value) => value !== null && value !== ""
Expand All @@ -16,9 +23,16 @@ const Citation = ({ citation, index }: CitationProps) => {
{Object.keys(citation).map((key, i) => (
<div key={i}>
<strong>
{"\u2022"} {key}
{"\u2022"} {citationKeyMap[key] || key}
</strong>
: {citation[key]}
:{" "}
{key === "source_url" && citation[key] ? ( // Check if the current key is 'source_url' and it exists
<a href={citation[key]} target="_blank" rel="noopener noreferrer">
{citation[key]}
</a>
) : (
citation[key]
)}
</div>
))}
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/web/components/NewQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function NewQuery() {
source_title: citation.Title,
source_name: citation.Name,
source_publish_date: citation.Published,
source_url: citation.URL,
};
});
card = card as ICard;
Expand Down

0 comments on commit 339c4a7

Please sign in to comment.