diff --git a/assets/css/inputs.css b/assets/css/inputs.css index 3c05127..8023fdc 100644 --- a/assets/css/inputs.css +++ b/assets/css/inputs.css @@ -1,14 +1,16 @@ .input { + box-sizing: border-box; padding: .5rem .75rem; font-size: 1rem; flex-basis: 0; border: solid 1px var(--grey-light-30); border-radius: .25rem; + background: var(--grey-light-60); font: inherit; &:focus { outline: none; - border-color: var(--primary-light-30); + border-color: var(--primary-light-50); } } diff --git a/assets/css/theme.css b/assets/css/theme.css index 36a3dba..b104c78 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -3,6 +3,8 @@ --primary-light-10: hsl(300, 50%, 40%); --primary-light-20: hsl(300, 50%, 50%); --primary-light-30: hsl(300, 50%, 60%); + --primary-light-40: hsl(300, 50%, 75%); + --primary-light-50: hsl(300, 50%, 80%); --grey-dark-40: #222; --grey-dark-30: #444; @@ -13,6 +15,8 @@ --grey-light-20: #ccc; --grey-light-30: #ddd; --grey-light-40: #eee; + --grey-light-50: #fafafa; + --grey-light-60: #fcfcfc; --background-dark-20: #eee; --background-dark-10: #f8f8f8; diff --git a/assets/js/api.js b/assets/js/api.js index 0145318..a6d1495 100644 --- a/assets/js/api.js +++ b/assets/js/api.js @@ -15,7 +15,7 @@ function getQuery(data) { } export async function get(path, query = {}) { - const res = await fetch(`${path}${getQuery(query)}`); + const res = await fetch(`/api${path}${getQuery(query)}`); const body = await res.json(); if (res.ok) { @@ -26,7 +26,7 @@ export async function get(path, query = {}) { } export async function post(path, data, { query } = {}) { - const res = await fetch(`${path}${getQuery(query)}`, { + const res = await fetch(`/api${path}${getQuery(query)}`, { method: 'POST', body: JSON.stringify(data), ...postHeaders, @@ -46,7 +46,7 @@ export async function post(path, data, { query } = {}) { } export async function patch(path, data, { query } = {}) { - const res = await fetch(`${path}${getQuery(query)}`, { + const res = await fetch(`/api${path}${getQuery(query)}`, { method: 'PATCH', body: JSON.stringify(data), ...postHeaders, @@ -66,7 +66,7 @@ export async function patch(path, data, { query } = {}) { } export async function del(path, { data, query } = {}) { - const res = await fetch(`${path}${getQuery(query)}`, { + const res = await fetch(`/api${path}${getQuery(query)}`, { method: 'DELETE', body: JSON.stringify(data), ...postHeaders, diff --git a/assets/js/navigate.js b/assets/js/navigate.js index 8b6b7d8..8176a35 100644 --- a/assets/js/navigate.js +++ b/assets/js/navigate.js @@ -2,3 +2,7 @@ export default function navigate(path) { window.location.href = path; } + +export function reload() { + window.location.reload(); +} diff --git a/components/comments/comment.vue b/components/comments/comment.vue new file mode 100644 index 0000000..3caa064 --- /dev/null +++ b/components/comments/comment.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/components/posts/post.vue b/components/posts/post.vue index ac40b2e..c390ef9 100644 --- a/components/posts/post.vue +++ b/components/posts/post.vue @@ -1,24 +1,36 @@ diff --git a/pages/posts/post.page.route.js b/pages/posts/post.page.route.js new file mode 100644 index 0000000..5dae8c1 --- /dev/null +++ b/pages/posts/post.page.route.js @@ -0,0 +1 @@ +export default '/s/@id/post/@postId'; diff --git a/pages/posts/post.page.server.js b/pages/posts/post.page.server.js new file mode 100644 index 0000000..ad8f502 --- /dev/null +++ b/pages/posts/post.page.server.js @@ -0,0 +1,40 @@ +import { RenderErrorPage } from 'vite-plugin-ssr/RenderErrorPage'; +import { fetchShelf } from '../../src/shelves'; +import { fetchPost } from '../../src/posts'; +import { fetchPostComments } from '../../src/comments'; + +async function getPageData(pageContext) { + const [shelf, post, comments] = await Promise.all([ + fetchShelf(pageContext.routeParams.id), + fetchPost(pageContext.routeParams.postId), + fetchPostComments(pageContext.routeParams.postId), + ]); + + if (!shelf) { + throw RenderErrorPage({ + pageContext: { + pageProps: { + errorInfo: 'This shelf does not exist', + }, + }, + }); + } + + if (!post) { + throw RenderErrorPage({ + pageContext: { + pageProps: { + errorInfo: 'This post does not exist', + }, + }, + }); + } + + return { + shelf, + post, + comments, + }; +} + +export { getPageData }; diff --git a/pages/posts/post.page.vue b/pages/posts/post.page.vue new file mode 100644 index 0000000..a86ea8c --- /dev/null +++ b/pages/posts/post.page.vue @@ -0,0 +1,107 @@ +