next/pages/story/[id]/chapters.vue
2023-12-06 21:44:59 -05:00

32 lines
745 B
Vue

<script lang="ts" setup>
import { storyMiddleware } from "~/lib/client/middleware";
import { IStory } from "~/models/stories";
definePageMeta({
middleware: [storyMiddleware],
});
const rtr = useRoute();
const { data: story, error } = await useApiFetch<IStory>(
`/story/${rtr.params.id}`,
);
</script>
<template>
<a-list :data-source="story.chapters">
<template #renderItem="{ item, index }">
<a-list-item>
<a-list-item-meta>
<template #title>
<b>
<nuxt-link :to="`/story/${story._id}/${index + 1}`">
{{ item.title || "Untitled" }}
</nuxt-link>
</b>
</template>
</a-list-item-meta>
<div v-html="item.summary"></div>
</a-list-item>
</template>
</a-list>
</template>