add blog
This commit is contained in:
1 parent
36338ed0d7
commit
7fe8f5d154
96 files changed
+21326
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<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>
|
||||
Reference in new issue
Block a user