Skip to content

Commit

Permalink
docs: show news feed on homepage
Browse files Browse the repository at this point in the history
Adds the most recent release from the Github releases feed to the homepage, so that users know when something changes.

This commit also adds a call to action for anyone who can contribute to the site.
  • Loading branch information
arxanas committed Oct 6, 2020
1 parent 3caf304 commit 13c5439
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/components/GithubReportIssueBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
</template>

<script lang="ts">
import { REPO_GITHUB_ISSUES_URL } from "@/constants";
import Vue from "vue";
import Component from "vue-class-component";
@Component
export default class extends Vue {
public repoGithubIssuesUrl: string =
"https://github.com/arxanas/smashtraining/issues/new";
get issueUrl(): string {
const url = new URL(this.repoGithubIssuesUrl);
const url = new URL(REPO_GITHUB_ISSUES_URL);
url.searchParams.set(
"body",
`Page: ${window.location.toString()}
Expand Down
9 changes: 9 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const REPO_GITHUB_URL = "https://github.com/arxanas/smashtraining";

export const REPO_GITHUB_ISSUES_URL =
"https://github.com/arxanas/smashtraining/issues/new";

export const REPO_GITHUB_RELEASES_API_URL =
"https://api.github.com/repos/arxanas/smashtraining/releases/latest";

export const CONTACT_HREF = "mailto:[email protected]";
68 changes: 67 additions & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
<template>
<v-container>
<v-row v-if="latestReleaseInfo !== null">
<v-col cols="12">
<v-card>
<v-card-text>
<v-icon left>mdi-information</v-icon>
<b>Smash Training {{ latestReleaseInfo.tag_name }}</b> (&ldquo;{{
latestReleaseInfo.name
}}&rdquo;) was released <b>{{ releaseTime }}</b
>.
</v-card-text>
<v-divider />
<v-card-text>
{{ latestReleaseInfo.body.split("\n")[0] }}
<a :href="latestReleaseInfo.html_url">See more...</a>
</v-card-text>
<v-divider />
<v-card-text>
Can you contribute exercises?
<a :href="contactHref">Contact me</a> or visit the
<a :href="githubUrl">Github repo</a>.
</v-card-text>
</v-card>
</v-col>
</v-row>

<v-row>
<v-col cols="12">
<v-card>
Expand Down Expand Up @@ -252,16 +277,57 @@
vertical-align: text-top;
width: 1rem;
}
.release-info-title {
color: #666;
font-weight: 700;
text-transform: uppercase;
}
</style>

<script lang="ts">
import CharacterSelector from "@/components/training/CharacterSelector.vue";
import {
CONTACT_HREF,
REPO_GITHUB_RELEASES_API_URL,
REPO_GITHUB_URL,
} from "@/constants";
import moment, { HTML5_FMT } from "moment";
import Vue from "vue";
import Component from "vue-class-component";
interface ReleaseInfo {
tag_name: string;
html_url: string;
created_at: string;
published_at: string;
name: string;
body: string;
}
@Component({
name: "home",
components: { CharacterSelector },
})
export default class extends Vue {}
export default class extends Vue {
public contactHref = CONTACT_HREF;
public githubUrl = REPO_GITHUB_URL;
public latestReleaseInfo: ReleaseInfo | null = null;
public async created() {
const latestReleaseInfoRequest = await fetch(REPO_GITHUB_RELEASES_API_URL);
this.latestReleaseInfo = await latestReleaseInfoRequest.json();
}
get releaseTime(): string {
if (this.latestReleaseInfo === null) {
return "unknown release time";
} else {
return moment(
this.latestReleaseInfo.created_at,
"YYYY-MM-DDTHH:mm:ssZ",
).fromNow();
}
}
}
</script>

0 comments on commit 13c5439

Please sign in to comment.