Skip to content

Commit

Permalink
Reformat Oracc numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Oct 31, 2023
1 parent 49bd95b commit 57348df
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
32 changes: 24 additions & 8 deletions src/fragmentarium/ui/info/ExternalNumberLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export function YalePeabodyLink({ number }: { number: string }): JSX.Element {
/>
)
}
export function OraccLink({

function OraccLink({
project,
cdliNumber,
}: {
Expand All @@ -106,17 +107,32 @@ export function OraccLink({
project === 'ccp'
? 'https://ccp.yale.edu/'
: `https://oracc.org/${project}/`
return (
<ExternalLink
href={`${baseUrl}${encodeURIComponent(cdliNumber)}`}
aria-label={`Oracc text ${project} ${cdliNumber}`}
>
{project.toUpperCase()}
</ExternalLink>
)
}

const url = `${baseUrl}${encodeURIComponent(cdliNumber)}`
export function OraccLinks({
projects,
cdliNumber,
}: {
projects: readonly string[]
cdliNumber: string
}): JSX.Element {
return (
<>
{'Oracc ('}
<ExternalLink
href={url}
aria-label={`Oracc text ${project} ${cdliNumber}`}
>
{project.toUpperCase()}
</ExternalLink>
{projects.map((project, index) => (
<>
{index !== 0 && ', '}
<OraccLink project={project} cdliNumber={cdliNumber} key={index} />
</>
))}
{')'}
</>
)
Expand Down
14 changes: 9 additions & 5 deletions src/fragmentarium/ui/info/ExternalResources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
HilprechtHeidelbergLink,
BmIdLink,
YalePeabodyLink,
OraccLink,
OraccLinks,
} from './ExternalNumberLink'
import _ from 'lodash'

type ExternalLinkComponent = ({ number }: { number: string }) => JSX.Element

Expand Down Expand Up @@ -40,11 +41,14 @@ export default function ExternalResources({
</li>
)
)}
{fragment.oraccNumbers.map((project, index) => (
<li key={`oracc-${index}`}>
<OraccLink project={project} cdliNumber={fragment.cdliNumber} />
{!_.isEmpty(fragment.oraccNumbers) && (
<li>
<OraccLinks
projects={fragment.oraccNumbers}
cdliNumber={fragment.cdliNumber}
/>
</li>
))}
)}
</ul>
)
}

0 comments on commit 57348df

Please sign in to comment.