diff options
author | gumi <git@gumi.ca> | 2019-07-24 15:21:59 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2019-07-24 15:21:59 -0400 |
commit | 50e60e5c4b2e4be3946598bca3967c485735aab3 (patch) | |
tree | 5de853daf4b7a38be1f23c63e90a8255270b6e39 /src | |
parent | c9874173faea3ddb237592c26e09abb95885d444 (diff) | |
download | website-50e60e5c4b2e4be3946598bca3967c485735aab3.tar.gz website-50e60e5c4b2e4be3946598bca3967c485735aab3.tar.bz2 website-50e60e5c4b2e4be3946598bca3967c485735aab3.tar.xz website-50e60e5c4b2e4be3946598bca3967c485735aab3.zip |
allow loading news from file (for non-static hosting)
Diffstat (limited to 'src')
-rw-r--r-- | src/components/News.vue | 8 |
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"); |