diff --git a/lib/changelog.hook.ts b/lib/changelog.hook.ts index f46383f..48d5f6d 100644 --- a/lib/changelog.hook.ts +++ b/lib/changelog.hook.ts @@ -45,7 +45,18 @@ export function useChangelogs(config: UpdateHiveConfig): UpdateHiveHookResult { throw new Error(error.message); } - setData(await result.json()); + const resultData: Changelog[] | undefined = await result.json(); + + if (resultData) { + setData( + resultData.sort((a, b) => { + return ( + new Date(b.releaseDate).getTime() - + new Date(a.releaseDate).getTime() + ); + }), + ); + } } catch (error) { if (error instanceof Error) { setError(error.message); diff --git a/lib/changelog.types.ts b/lib/changelog.types.ts index 72c3866..e20fe88 100644 --- a/lib/changelog.types.ts +++ b/lib/changelog.types.ts @@ -53,7 +53,7 @@ export type Changelog = { product: string; variant: VariantType; version: string; - releaseDate: Date; + releaseDate: string; title?: string; description?: string; entries: ChangelogEntryInterface[]; diff --git a/lib/components/ChangelogList/ChangelogList.tsx b/lib/components/ChangelogList/ChangelogList.tsx index 5bfebc8..132c42c 100644 --- a/lib/components/ChangelogList/ChangelogList.tsx +++ b/lib/components/ChangelogList/ChangelogList.tsx @@ -6,7 +6,6 @@ import { ChangeTypeMap, getTypeColor, groupChangelogsByComponents, - reorderChangelogs, ungroupedChangelogs, } from '../changelog.util.ts'; import ComponentList from './_internal/ComponentList.tsx'; @@ -40,13 +39,11 @@ export const ChangelogList: React.FC = ({ return undefined; } - const reorderedChangelogs = reorderChangelogs(data); - if (groupBy === GroupBy.NONE) { - return ungroupedChangelogs(reorderedChangelogs); + return ungroupedChangelogs(data); } - return groupChangelogsByComponents(reorderedChangelogs); + return groupChangelogsByComponents(data); }, [data, groupBy]); return ( diff --git a/lib/components/ChangelogList/MinimalChangelogList.tsx b/lib/components/ChangelogList/MinimalChangelogList.tsx index 04a339f..57d1886 100644 --- a/lib/components/ChangelogList/MinimalChangelogList.tsx +++ b/lib/components/ChangelogList/MinimalChangelogList.tsx @@ -4,7 +4,6 @@ import { ChangelogWithComponents, ChangeTypeMap, getTypeColor, - reorderChangelogs, ungroupedChangelogs, } from '../changelog.util.ts'; import { ChangeType } from '../../changelog.types.ts'; @@ -33,8 +32,7 @@ export const MinimalChangelogList: React.FC = ({ return undefined; } - const reorderedChangelogs = reorderChangelogs(data); - return ungroupedChangelogs(reorderedChangelogs); + return ungroupedChangelogs(data); }, [data]); return ( diff --git a/lib/components/changelog.util.ts b/lib/components/changelog.util.ts index e968aa6..9135c4a 100644 --- a/lib/components/changelog.util.ts +++ b/lib/components/changelog.util.ts @@ -31,10 +31,6 @@ export const getTypeColor = (type: ChangeType): string => { } }; -export const reorderChangelogs = (changelogs: Changelog[]) => { - return changelogs.toReversed(); -}; - export interface ChangelogWithComponents { version: string; description?: string;