diff --git a/extensions/webviews/interfaces.ts b/extensions/webviews/interfaces.ts index 5ba4c81..eb2cfb8 100644 --- a/extensions/webviews/interfaces.ts +++ b/extensions/webviews/interfaces.ts @@ -13,7 +13,13 @@ export interface IPost { new: IChangeType[]; breaking: IChangeType[]; } - +export interface IPostNormalized { + title: String; + version: String; + fixed: String[]; + new: String[]; + breaking: String[]; +} export interface SettingsChangedMessage { type: 'settingsChanged'; config: IThemeCustomSettings; diff --git a/extensions/webviews/ui/release-notes/index.ts b/extensions/webviews/ui/release-notes/index.ts index 68ab198..25dba37 100644 --- a/extensions/webviews/ui/release-notes/index.ts +++ b/extensions/webviews/ui/release-notes/index.ts @@ -1,6 +1,6 @@ import * as sanityClient from '@sanity/client'; -import {IPost} from '../../interfaces'; +import {IPost, IPostNormalized} from '../../interfaces'; const getClient = () => sanityClient({ projectId: 'v475t82f', @@ -8,21 +8,24 @@ const getClient = () => sanityClient({ }); const getReleaseNotes = (): Promise => { - const query = '*[_type == "release"] | order(_createdAt desc)'; + const query = '*[_type == "release"] | order(version desc)'; const client = getClient(); return client.fetch(query); }; -const renderTemplate = (posts: IPost[]) => { +const renderTemplate = (posts: IPostNormalized[]) => { return `${posts.reduce((acc, {version, title, fixed, new: newItems, breaking}) => acc.concat(`
${version}

${title}

`), '')}`; };