feat(ui): add changelog view

This commit is contained in:
2021-03-13 01:30:45 +01:00
parent 82401d52a5
commit 74e8c5bb83
9 changed files with 100 additions and 7 deletions

View File

@ -0,0 +1,65 @@
<script>
import Commit from "components/Changelog/Commit.svelte";
import { commitStore, route } from "stores";
$: if ($commitStore.length) {
localStorage.setItem(
"currentCommit",
$commitStore[$commitStore.length - 1].id
);
}
$: commits =
$commitStore.length &&
$commitStore
.filter((commit) => {
return (
commit.subject.startsWith("feat") &&
commit.subject.replace("feat:", "").length > 3
);
})
.map((commit) => {
commit.subject = commit.subject.replace("feat:", "").trim();
commit.date = new Date(commit.date);
return commit;
});
let day = $commitStore.length && new Date($commitStore[0].date).getDay();
const checkDate = (commit) => {
console.log(commit);
const d = new Date(commit.date);
if (d.getDay() != day) {
day = d.getDay();
return true;
}
return false;
};
const prettyDate = (date) => {
return new Date(date).toLocaleDateString();
};
</script>
<main>
<button on:click={() => ($route = "list")}>exit</button>
<h1>Changelog</h1>
{#each commits as commit}
{#if checkDate(commit)}
<h3>
{prettyDate(commit.date)}
</h3>
{/if}
<Commit {commit} />
{/each}
</main>
<style>
main {
max-width: 640px;
margin: 0 auto;
}
</style>

View File

@ -1,2 +1,3 @@
export { default as main } from "./main.svelte"
export { default as list } from "./list.svelte"
export { default as list } from "./list.svelte"
export { default as changelog } from "./changelog.svelte"