diff --git a/static-site/src/components/ListResources/useDataFetch.ts b/static-site/src/components/ListResources/useDataFetch.ts index c18db4399..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 = { @@ -83,9 +77,14 @@ function partitionByPathogen( nameParts, sortingName: _sortableName(nameParts), url: `/${pathPrefix}${name}`, - lastUpdated: sortedDates.at(-1), }; 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; resourceDetails.nVersions = sortedDates.length;