blob: 8a58514dfb6cd5a8184f8955210a418ee3a36448 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<template>
<div class="news" v-if="count">
<span v-if="!entries.length">(no news entries)</span>
<article class="entry" v-for="entry in entries" :id="entry.date">
<a :href="'#' + entry.date">{{ entry.title }}</a>
<time :datetime="entry.date" class="date">{{ entry.date }}</time>
<section class="body" v-html="entry.html"></section>
</article>
</div>
</template>
<style scoped>
.news .entry {
margin-bottom: 1em;
&:nth-of-type(1n + 2) {
margin-top: 2em;
}
& > a {
text-decoration: none;
color: inherit;
font-weight: bold;
}
& > .date {
float: right;
}
& .body {
margin-top: 5px;
}
}
</style>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import newsEntries from "@/assets/news.json";
interface NewsEntry {
title: string;
date: string;
author: string;
html: string;
}
@Component
export default class News extends Vue {
@Prop({ default: Infinity }) private count!: number;
@Prop({ default: 0 }) private from!: number;
private entries: NewsEntry[] = (newsEntries as NewsEntry[]).slice(this.from, this.count);
}
</script>
|