43 lines
937 B
Vue
43 lines
937 B
Vue
<template lang="pug">
|
|
post-query(:defaults="defaults")
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { Vue, Component } from 'nuxt-property-decorator'
|
|
import PostQuery from '@/components/PostQuery.vue'
|
|
|
|
@Component({
|
|
components: {
|
|
PostQuery,
|
|
},
|
|
})
|
|
export default class PageIndex extends Vue {
|
|
defaults = {
|
|
posts: [],
|
|
count: 0,
|
|
}
|
|
|
|
async asyncData ({ $axios, $payloadURL, route }: any) {
|
|
if (process.static && process.client && $payloadURL) {
|
|
return $axios.$get($payloadURL(route))
|
|
}
|
|
|
|
const now = new Date().toISOString()
|
|
let ps: any[] = require('@/static/build/header/posts.json')
|
|
ps = ps.filter((p) => p.date && p.date < now && p.path.startsWith('blog/'))
|
|
|
|
const posts = ps.slice(0, 5).map((h) => {
|
|
h.teaser = require(`@/static/build/teaser/${h.path}`).default
|
|
return h
|
|
})
|
|
|
|
return {
|
|
defaults: {
|
|
posts,
|
|
count: ps.length,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
</script>
|