mirror of
https://github.com/ArthurDanjou/website-old.git
synced 2026-01-23 16:30:42 +01:00
Fix fetching
This commit is contained in:
@@ -30,13 +30,23 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "@nuxtjs/composition-api";
|
||||
import {defineComponent, useAsync, useContext} from "@nuxtjs/composition-api";
|
||||
import {Post} from "../../@types/types";
|
||||
|
||||
export default defineComponent({
|
||||
name: "PostsHome",
|
||||
props: {
|
||||
posts: {
|
||||
default: () => [],
|
||||
setup() {
|
||||
const { $content, i18n } = useContext()
|
||||
|
||||
const posts = useAsync(() => {
|
||||
return $content(`articles/${i18n.locale}`)
|
||||
.sortBy('date', 'asc')
|
||||
.limit(3)
|
||||
.fetch<Post>()
|
||||
}, 'posts')
|
||||
|
||||
return {
|
||||
posts
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -28,13 +28,22 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "@nuxtjs/composition-api";
|
||||
import {defineComponent, useAsync, useContext} from "@nuxtjs/composition-api";
|
||||
import {Project} from "../../@types/types";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ProjectsHome",
|
||||
props: {
|
||||
projects: {
|
||||
default: () => [],
|
||||
setup() {
|
||||
const { $content } = useContext()
|
||||
|
||||
const projects = useAsync(() => {
|
||||
return $content(`projects`)
|
||||
.limit(3)
|
||||
.fetch<Project>()
|
||||
}, 'projects')
|
||||
|
||||
return {
|
||||
projects
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user