summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2019-07-24 15:21:59 -0400
committergumi <git@gumi.ca>2019-07-24 15:21:59 -0400
commit50e60e5c4b2e4be3946598bca3967c485735aab3 (patch)
tree5de853daf4b7a38be1f23c63e90a8255270b6e39
parentc9874173faea3ddb237592c26e09abb95885d444 (diff)
downloadwebsite-50e60e5c4b2e4be3946598bca3967c485735aab3.tar.gz
website-50e60e5c4b2e4be3946598bca3967c485735aab3.tar.bz2
website-50e60e5c4b2e4be3946598bca3967c485735aab3.tar.xz
website-50e60e5c4b2e4be3946598bca3967c485735aab3.zip
allow loading news from file (for non-static hosting)
-rw-r--r--src/components/News.vue8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/components/News.vue b/src/components/News.vue
index c92e17f..606c1a7 100644
--- a/src/components/News.vue
+++ b/src/components/News.vue
@@ -61,6 +61,7 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
+import newsEntries from "@/assets/news.json";
interface NewsEntry {
id: string;
@@ -74,9 +75,14 @@ interface NewsEntry {
export default class News extends Vue {
@Prop({ default: Infinity }) private count!: number;
@Prop({ default: 0 }) private from!: number;
- private entries: NewsEntry[] = [];
+ private entries: NewsEntry[] = (newsEntries as NewsEntry[]).slice(this.from, this.count);
mounted () {
+ if (!process.env.VUE_APP_NEWS_JSON || !process.env.VUE_APP_NEWS_JSON.startsWith("https")) {
+ // TODO: allow arbitrary paths (no hardcoded news.json)
+ return;
+ }
+
// restore from cache while we're loading a fresh copy
if (Reflect.has(self, "localStorage")) {
let newsCache = localStorage.getItem("newsCache");