Added front page, moved shelf navigation to header.

This commit is contained in:
2023-06-25 23:50:08 +02:00
parent 77085c5755
commit b3e5769d39
27 changed files with 554 additions and 109 deletions

View File

@@ -121,7 +121,9 @@ async function signup() {
<style scoped>
.content {
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
align-items: center;
}

View File

@@ -91,6 +91,8 @@ async function signup() {
<style scoped>
.content {
display: flex;
flex-grow: 1;
flex-direction: column;
justify-content: center;
align-items: center;
}

View File

@@ -1,10 +1,12 @@
import { fetchShelves } from '../../src/shelves';
import { fetchUserPosts, fetchAllPosts } from '../../src/posts';
async function getPageData() {
const shelves = await fetchShelves();
async function getPageData(pageContext) {
const posts = pageContext.session.user
? await fetchUserPosts(pageContext.session.user)
: await fetchAllPosts();
return {
shelves,
posts,
};
}

View File

@@ -1,37 +1,20 @@
<template>
<div class="content">
<ul>
<li><a
href="/shelf/create"
class="link"
>Create new shelf</a></li>
<li v-if="!me"><a
href="/account/login"
class="link"
>Log in</a></li>
<li><a
href="/account/create"
class="link"
>Sign up</a></li>
</ul>
<ul>
<ul class="posts nolist">
<li
v-for="shelf in shelves"
:key="shelf.id"
><a
:href="`/s/${shelf.slug}`"
class="link"
>{{ shelf.slug }}</a></li>
v-for="post in posts"
:key="post.id"
>
<Post :post="post" />
</li>
</ul>
</div>
</template>
<script setup>
import { usePageContext } from '../../renderer/usePageContext';
import Post from '../../components/posts/post.vue';
const { me, pageData } = usePageContext();
const { shelves } = pageData;
const { pageData } = usePageContext();
const { posts } = pageData;
</script>

View File

@@ -1 +1 @@
export default '/s/@shelfId/post/@postId';
export default '/s/@shelfId/post/@postId/@postSlug?';

View File

@@ -65,7 +65,7 @@ const {
<style scoped>
.content {
width: 100%;
padding: 0;
}
.body {

View File

@@ -3,7 +3,7 @@ import { fetchShelf } from '../../src/shelves';
import { fetchShelfPosts } from '../../src/posts';
async function getPageData(pageContext) {
const shelf = await fetchShelf(pageContext.routeParams.id);
const shelf = await fetchShelf(pageContext.routeParams.id, { user: pageContext.session.user });
const posts = await fetchShelfPosts(pageContext.routeParams.id, { user: pageContext.session.user, limit: 50 });
if (!shelf) {

View File

@@ -33,6 +33,7 @@ const {
.posts {
width: 100%;
display: flex;
flex-direction: column;
margin-bottom: 1rem;
}