2023-06-05 23:30:46 +00:00
|
|
|
<template>
|
|
|
|
<div class="content">
|
|
|
|
<h3>{{ shelf.slug }}</h3>
|
|
|
|
|
|
|
|
<ul class="posts nolist">
|
|
|
|
<li
|
|
|
|
v-for="post in posts"
|
|
|
|
:key="post.id"
|
2023-06-25 17:52:00 +00:00
|
|
|
>
|
|
|
|
<Post
|
|
|
|
:post="post"
|
|
|
|
:shelf="shelf"
|
|
|
|
/>
|
|
|
|
</li>
|
2023-06-05 23:30:46 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<form
|
|
|
|
class="form compose"
|
|
|
|
@submit.prevent="submitPost"
|
|
|
|
>
|
|
|
|
<div class="form-row">
|
|
|
|
<input
|
|
|
|
v-model="title"
|
|
|
|
placeholder="Title"
|
|
|
|
class="input"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
<input
|
|
|
|
v-model="link"
|
|
|
|
class="input"
|
|
|
|
placeholder="Link"
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-row">
|
|
|
|
<textarea
|
|
|
|
v-model="body"
|
|
|
|
placeholder="Body"
|
|
|
|
class="input body"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-actions">
|
|
|
|
<button class="button button-submit">Post</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref } from 'vue';
|
2023-06-25 17:52:00 +00:00
|
|
|
import Post from '../../components/posts/post.vue';
|
2023-06-05 23:30:46 +00:00
|
|
|
|
2023-06-25 17:52:00 +00:00
|
|
|
import * as api from '../../assets/js/api';
|
|
|
|
import { navigate } from '../../assets/js/navigate';
|
|
|
|
import { usePageContext } from '../../renderer/usePageContext';
|
2023-06-05 23:30:46 +00:00
|
|
|
|
|
|
|
const { pageData, routeParams } = usePageContext();
|
|
|
|
|
|
|
|
const {
|
|
|
|
shelf,
|
|
|
|
posts,
|
|
|
|
} = pageData;
|
|
|
|
|
|
|
|
const title = ref();
|
|
|
|
const link = ref();
|
|
|
|
const body = ref();
|
|
|
|
|
|
|
|
async function submitPost() {
|
2023-06-25 17:52:00 +00:00
|
|
|
const post = await api.post(`/shelves/${routeParams.id}/posts`, {
|
2023-06-05 23:30:46 +00:00
|
|
|
title: title.value,
|
|
|
|
link: link.value,
|
|
|
|
body: body.value,
|
|
|
|
});
|
2023-06-25 17:52:00 +00:00
|
|
|
|
|
|
|
navigate(`/s/${shelf.slug}/post/${post.id}`);
|
2023-06-05 23:30:46 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.posts {
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
|
|
|
</style>
|