mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
feat: get version changelog from github
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import showdown from "showdown";
|
||||||
|
|
||||||
export const appVersion = {
|
export const appVersion = {
|
||||||
formatted: format(
|
formatted: format(
|
||||||
process.env.REACT_APP_VERSION,
|
process.env.REACT_APP_VERSION,
|
||||||
@@ -53,4 +55,28 @@ export function getServiceWorkerVersion(serviceWorker) {
|
|||||||
serviceWorker.postMessage({ type: "GET_VERSION" });
|
serviceWorker.postMessage({ type: "GET_VERSION" });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var converter = new showdown.Converter();
|
||||||
|
converter.setFlavor("github");
|
||||||
|
|
||||||
|
export async function getChangelog(tag) {
|
||||||
|
try {
|
||||||
|
if (!tag) return;
|
||||||
|
|
||||||
|
const url = `https://api.github.com/repos/streetwriters/notesnook/releases/tags/v${tag}`;
|
||||||
|
const response = await fetch(url, {
|
||||||
|
headers: { Accept: "application/json" },
|
||||||
|
});
|
||||||
|
if (!response.ok) return "No changelog found.";
|
||||||
|
|
||||||
|
const release = await response.json();
|
||||||
|
if (!release) return "No changelog found.";
|
||||||
|
|
||||||
|
const { body } = release;
|
||||||
|
|
||||||
|
const html = converter.makeHtml(body);
|
||||||
|
return html;
|
||||||
|
} catch {
|
||||||
|
return "No changelog found.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user