Skip to content

Commit

Permalink
Merge pull request #656 from colonial-heritage/feat-research-guides-d…
Browse files Browse the repository at this point in the history
…atamodel

feat: updated datamodel of research guides
  • Loading branch information
sdevalk authored Jun 20, 2024
2 parents b512c50 + 4a4685a commit 3a9a8d5
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 88 deletions.
4 changes: 2 additions & 2 deletions apps/researcher/src/app/[locale]/research-guide/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export default async function GuidePage({params}: Props) {
</div>
</div>
<div className="w-full md:w-1/3">
{guide.hasParts && guide.hasParts?.length > 0 && (
{guide.seeAlso && guide.seeAlso?.length > 0 && (
<>
<h2 className="mb-2">{t('relatedItems')}</h2>
<div className="flex flex-col gap-2 mb-4">
{guide.hasParts?.map(item => (
{guide.seeAlso?.map(item => (
<Link
key={item.id}
href={`/research-guide/${encodeRouteSegment(item.id)}`}
Expand Down
4 changes: 2 additions & 2 deletions apps/researcher/src/app/[locale]/research-guide/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {MDXRemote} from 'next-mdx-remote/rsc';

export default async function Page() {
const locale = (await getLocale()) as LocaleEnum;
const topLevels = await researchGuides.getByTopLevel({locale});
const topLevels = await researchGuides.getTopLevels({locale});
const t = await getTranslations('ResearchGuide');

if (!topLevels.length) {
Expand All @@ -27,7 +27,7 @@ export default async function Page() {
<div className="bg-consortium-sand-100 rounded mt-6 -mx-4 pr-10">
<h2 className="px-4 pt-4">{t('level1Title')}</h2>
<div className="pb-4 columns-3 gap-10">
{topLevel.hasParts?.map(item => (
{topLevel.seeAlso?.map(item => (
<Link
key={item.id}
href={`/research-guide/${encodeRouteSegment(item.id)}`}
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/research-guides/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {Place, Term, Thing} from '../definitions';
export type Citation = Thing & {url?: string};

export type ResearchGuide = Thing & {
identifier?: string;
abstract?: string;
text?: string;
encodingFormat?: string;
contentLocations?: Place[];
keywords?: Term[];
citations?: Citation[];
isPartOf?: ResearchGuide[];
hasParts?: ResearchGuide[];
seeAlso?: ResearchGuide[];
};
126 changes: 101 additions & 25 deletions packages/api/src/research-guides/fetcher.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,103 @@ beforeEach(() => {
});
});

describe('getByTopLevel', () => {
describe('getTopLevels', () => {
it('returns the top level guides', async () => {
const researchGuides = await researchGuideFetcher.getByTopLevel();
const researchGuides = await researchGuideFetcher.getTopLevels();

// The sorting order is undefined and can change - don't use toStrictEqual()
expect(researchGuides).toMatchObject([
{
id: 'https://guides.example.org/top-level',
id: 'https://guides.example.org/top-set',
name: 'Digital research guide',
abstract:
'Research aides for conducting provenance research into colonial collections',
text: 'Digital research guide',
encodingFormat: 'text/markdown',
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-3-set',
identifier: '3',
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-3c',
name: 'Kunsthandel Van Lier',
seeAlso: [
{
id: 'https://guides.example.org/level-2a',
name: 'Military and navy',
},
],
},
{
id: 'https://guides.example.org/level-3a',
name: 'Royal Cabinet of Curiosities',
seeAlso: [
{
id: 'https://guides.example.org/level-2c',
name: 'Trade',
},
],
},
]),
},
{
id: 'https://guides.example.org/level-2-set',
identifier: '2',
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-2c',
name: 'Trade',
seeAlso: [
{
id: 'https://guides.example.org/level-3c',
name: 'Kunsthandel Van Lier',
},
],
},
{
id: 'https://guides.example.org/level-2a',
name: 'Military and navy',
seeAlso: [
{
id: 'https://guides.example.org/level-3a',
name: 'Royal Cabinet of Curiosities',
},
],
},
]),
},
{
id: 'https://guides.example.org/level-1-set',
identifier: '1',
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-1b',
name: 'How can I use the data hub for my research?',
},
{
id: 'https://guides.example.org/level-1c',
name: 'Sources',
seeAlso: [
{
id: 'https://guides.example.org/level-2c',
name: 'Trade',
},
],
},
{
id: 'https://guides.example.org/level-1a',
name: 'Doing research',
seeAlso: [
{
id: 'https://guides.example.org/level-2a',
name: 'Military and navy',
},
],
},
]),
},
]),
},
]);
});
Expand Down Expand Up @@ -85,18 +175,12 @@ describe('getById', () => {
'Army and Navy personnel who operated in colonized territories collected objects in various ways during the colonial era.',
text: 'Dutch authority in the [Dutch East Indies](https://www.geonames.org/1643084/republic-of-indonesia.html), [Suriname](https://www.geonames.org/3382998/republic-of-suriname.html) and on the [Caribbean Islands](https://www.geonames.org/8505032/netherlands-antilles.html) relied heavily on the use of the military...',
encodingFormat: 'text/markdown',
hasParts: [
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-3a',
name: 'Royal Cabinet of Curiosities',
},
],
isPartOf: [
{
id: 'https://guides.example.org/level-1a',
name: 'Doing research',
},
],
]),
contentLocations: [
{
id: expect.stringContaining(
Expand Down Expand Up @@ -143,16 +227,12 @@ describe('get with localized names', () => {
abstract:
'Army and Navy personnel who operated in colonized territories collected objects in various ways during the colonial era.',
text: 'Dutch authority in the [Dutch East Indies](https://www.geonames.org/1643084/republic-of-indonesia.html), [Suriname](https://www.geonames.org/3382998/republic-of-suriname.html) and on the [Caribbean Islands](https://www.geonames.org/8505032/netherlands-antilles.html) relied heavily on the use of the military...',
hasParts: [
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-3a',
name: 'Royal Cabinet of Curiosities',
},
],
isPartOf: [
{
name: 'Doing research',
},
],
]),
contentLocations: [
{
name: 'Netherlands Antilles',
Expand Down Expand Up @@ -185,16 +265,12 @@ describe('get with localized names', () => {
abstract:
'Leger- en marinepersoneel dat actief was in gekoloniseerde gebieden, verzamelde op verschillende manieren objecten tijdens het koloniale tijdperk.',
text: 'Het Nederlandse gezag in [Nederlands-Indië](https://www.geonames.org/1643084/republic-of-indonesia.html), [Suriname](https://www.geonames.org/3382998/republic-of-suriname.html) en op de [Caribische eilanden](https://www.geonames.org/8505032/netherlands-antilles.html) steunde in belangrijke mate op de inzet van het leger.',
hasParts: [
seeAlso: expect.arrayContaining([
{
id: 'https://guides.example.org/level-3a',
name: 'Koninklijk Kabinet van Zeldzaamheden',
},
],
isPartOf: [
{
name: 'Onderzoeken',
},
],
]),
contentLocations: [
{
name: 'Antillen',
Expand Down
Loading

0 comments on commit 3a9a8d5

Please sign in to comment.