vsc-material-theme/extensions/webviews/ui/release-notes/index.ts
Alessio Occhipinti dd14b71121 feat: added support for ext changelogs (WIP) (#275)
* feat: added support for ext changelogs

* chore: switch repo releases url
2018-10-24 16:28:05 +02:00

24 lines
1 KiB
TypeScript

import {IPost} from '../../interfaces';
const getReleaseNotes = (): Promise<object[]> => {
const uri = 'https://raw.githubusercontent.com/equinusocio/vsc-material-theme-releases/master/releases/index.json';
return fetch(uri).then(res => res.json());
};
const renderTemplate = (posts: IPost[]) => {
return `${posts.reduce((acc, {version, title, fixed, new: newItems, breaking}) => acc.concat(`<section class="Release">
<header class="Release__Header">
<span class="Release__Number">${version}</span>
<h2 class="Release__Title">${title}</h2>
</header>
<ul class="Release-List">
${fixed.reduce((accc, src) => accc.concat(`<li data-type="fixed">${src}</li>`), '')}
${newItems.reduce((accc, src) => accc.concat(`<li data-type="new">${src}</li>`), '')}
${breaking.reduce((accc, src) => accc.concat(`<li data-type="breaking">${src}</li>`), '')}
</ul>
</section>`), '')}`;
};
getReleaseNotes().then((res: IPost[]) => {
document.querySelector('.Container').innerHTML = renderTemplate(res);
});