Skip to content

Commit c3d558b

Browse files
authored
Merge pull request #27 from datopian/feat/source
Add Source to dataset details page
2 parents 9d9a728 + a3f327e commit c3d558b

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

components/dataset/individualPage/DatasetInfo.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import Link from "next/link";
2-
import { Resource, Tag } from "@portaljs/ckan";
3-
import { ArrowDownTrayIcon, ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/20/solid";
2+
import { Resource, Tag } from "@portaljs/ckan";
3+
import {
4+
ArrowDownTrayIcon,
5+
ChevronDownIcon,
6+
ChevronUpIcon,
7+
} from "@heroicons/react/20/solid";
48
import { getTimeAgo } from "@/lib/utils";
59
import { Dataset } from "@/schemas/dataset.interface";
610
import { RiExternalLinkLine } from "react-icons/ri";
@@ -110,6 +114,43 @@ export default function DatasetInfo({
110114
Created:{" "}
111115
{dataset.metadata_created && getTimeAgo(dataset.metadata_created)}
112116
</span>
117+
{dataset.source && dataset.source.length > 0 && (
118+
<div className="font-medium text-gray-500">
119+
<div className="flex items-start gap-1">
120+
<svg
121+
xmlns="http://www.w3.org/2000/svg"
122+
fill="none"
123+
viewBox="0 0 24 24"
124+
strokeWidth={1.5}
125+
stroke="currentColor"
126+
className="w-5 h-5 text-accent inline-block mt-0.5 flex-shrink-0"
127+
>
128+
<path
129+
strokeLinecap="round"
130+
strokeLinejoin="round"
131+
d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"
132+
/>
133+
</svg>
134+
<div className="flex flex-col gap-1">
135+
<span>Source{dataset.source.length > 1 ? "s" : ""}:</span>
136+
<div className="flex flex-col gap-1.5">
137+
{dataset.source.map((url, index) => (
138+
<a
139+
key={index}
140+
href={url}
141+
target="_blank"
142+
rel="noopener noreferrer"
143+
className="text-accent hover:text-darkaccent flex items-center gap-1 break-all transition"
144+
>
145+
<RiExternalLinkLine className="w-4 h-4 flex-shrink-0" />
146+
<span className="underline">{url}</span>
147+
</a>
148+
))}
149+
</div>
150+
</div>
151+
</div>
152+
</div>
153+
)}
113154
<span className="font-medium text-gray-500 inline">
114155
<svg
115156
xmlns="http://www.w3.org/2000/svg"
@@ -136,7 +177,7 @@ export default function DatasetInfo({
136177
!showFullDescription ? "line-clamp-4" : ""
137178
}`}
138179
>
139-
<MarkdownRenderer content={description}/>
180+
<MarkdownRenderer content={description} />
140181
</div>
141182
{isTruncated && (
142183
<button

schemas/dataset.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface Dataset {
3636
temporal_coverage_end?: string;
3737
coverage_type?: string;
3838
data_type?: string;
39+
source?: string[];
3940
}
4041

4142
export interface PackageSearchOptions {

0 commit comments

Comments
 (0)