diff --git a/static-site/src/components/ListResources/useDataFetch.ts b/static-site/src/components/ListResources/useDataFetch.ts index 54604d539..1f064fa5c 100644 --- a/static-site/src/components/ListResources/useDataFetch.ts +++ b/static-site/src/components/ListResources/useDataFetch.ts @@ -63,18 +63,12 @@ function partitionByPathogen( versioned: boolean, ) { return Object.entries(pathVersions).reduce((store: Record, [name, dates]) => { - const sortedDates = [...dates].sort(); - const nameParts = name.split('/'); if (nameParts[0] === undefined) { throw new InternalError(`Name is not properly formatted: '${name}'`); } - if (sortedDates[0] === undefined) { - throw new InternalError("Resource does not have any dates."); - } - const groupName = nameParts[0]; const resourceDetails: Resource = { @@ -85,6 +79,11 @@ function partitionByPathogen( url: `/${pathPrefix}${name}`, }; if (versioned) { + const sortedDates = [...dates].sort(); + if (sortedDates[0] === undefined) { + throw new InternalError("Resource does not have any dates."); + } + resourceDetails.lastUpdated = sortedDates.at(-1); resourceDetails.firstUpdated = sortedDates[0]; resourceDetails.dates = sortedDates;