Skip to content

Commit 2d2a938

Browse files
authored
Merge pull request #269 from performant-software/RB-web-identifiers
Adding web identifiers to detail pages
2 parents e543e7b + 6c99653 commit 2d2a938

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
import { getTranslations } from "@backend/i18n";
3+
import _ from 'underscore';
4+
import { getAuthorityURL } from "@root/src/utils/webAuthorities";
5+
6+
const { record } = Astro.props
7+
8+
const lang = Astro.currentLocale;
9+
const { t } = await getTranslations(lang);
10+
---
11+
{record.web_identifiers && (
12+
<>
13+
<div class="py-6">
14+
<h2 class="capitalize text-lg font-semibold">{t('webAuthorities')}</h2>
15+
<div class="text-neutral-800 break-words flex flex-col gap-2 pt-4">
16+
{ _.map(record.web_identifiers, (auth) => {
17+
const url = getAuthorityURL(auth.web_authority?.source_type, auth.identifier);
18+
return url ? (
19+
<a href={url} class="underline" target="_blank">{`${auth.web_authority?.source_type}: ${auth.identifier}`}</a>
20+
) : (
21+
<span>{`${auth.web_authority?.source_type}: ${auth.identifier}`}</span>
22+
)
23+
})}
24+
</div>
25+
</div>
26+
</>
27+
)}

src/apps/pages/RecordDetail/index.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import MediaContents from "./MediaContents";
66
import PlaceMap from "./PlaceMap";
77
import Relations from "./Relations.astro";
88
import UserDefined from "./UserDefined.astro";
9+
import Identifiers from "./Identifiers.astro";
910
1011
interface Props {
1112
coverUrl?: string;
@@ -85,6 +86,9 @@ for (const modelType of Object.keys(record.relatedRecords)) {
8586
record={record}
8687
excludes={excludes}
8788
/>
89+
<Identifiers
90+
record={record}
91+
/>
8892
{relations.manifests && (
8993
<MediaContents
9094
client:only="react"

src/i18n/i18n.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,9 @@
358358
"saveSearchContent": {
359359
"tinaLabel": "Saved Search (Content)",
360360
"defaultValue": "Your search has been saved. Navigate to the \"Saved\" list to view your saved search."
361+
},
362+
"webAuthorities": {
363+
"tinaLabel": "Web Authorities",
364+
"defaultValue": "Web Authorities"
361365
}
362366
}

src/utils/webAuthorities.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const getAuthorityURL = (sourceType: string, identifier: string) => {
2+
switch (sourceType) {
3+
case 'wikidata':
4+
return `https://www.wikidata.org/wiki/${identifier}`;
5+
case 'viaf':
6+
return `https://viaf.org/en/viaf/${identifier}`;
7+
default:
8+
return null;
9+
}
10+
}

tina/tina-lock.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)