From cd955091f380e69bb15a2d670fdec66314c0b510 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Mon, 15 Mar 2021 15:17:47 +0800 Subject: [PATCH] chore: fix mobile issues and category selection --- www/pages/blog.tsx | 47 +++++++++++++++++++++------------- www/pages/blog/[slug].tsx | 53 ++++++++++++++++++++++----------------- 2 files changed, 59 insertions(+), 41 deletions(-) diff --git a/www/pages/blog.tsx b/www/pages/blog.tsx index 1e76b31e77f..b25bbe01fe0 100644 --- a/www/pages/blog.tsx +++ b/www/pages/blog.tsx @@ -11,7 +11,7 @@ import { getSortedPosts, getAllCategories } from '~/lib/posts' import authors from 'lib/authors.json' import DefaultLayout from '~/components/Layouts/Default' -import { Typography, Badge, Space, Button } from '@supabase/ui' +import { Typography, Badge, Space, Select } from '@supabase/ui' export async function getStaticProps() { const allPostsData = getSortedPosts() @@ -31,20 +31,23 @@ export async function getStaticProps() { } function Blog(props: any) { - const [category, setCategory] = useState('') + const [category, setCategory] = useState('all') const [blogs, setBlogs] = useState(props.blogs) const { basePath } = useRouter() useEffect(() => { // Update the document title using the browser API + console.log('useeffect') + console.log(category) + console.log(props.blogs) setBlogs( - category - ? props.blogs.filter((post: any) => { + category === 'all' + ? props.blogs + : props.blogs.filter((post: any) => { const found = post.tags.includes(category) return found }) - : blogs ) }, [category]) @@ -81,23 +84,31 @@ function Blog(props: any) {
-
+
-
+
More posts from the team
+
+ + Select a category + + +
- - {props.categories.map((categoryId: string) => ( - - ))} -
{/*
    */} {blogs.map((blog: any, idx: any) => { diff --git a/www/pages/blog/[slug].tsx b/www/pages/blog/[slug].tsx index ca85adf9140..d47f9ec54d1 100644 --- a/www/pages/blog/[slug].tsx +++ b/www/pages/blog/[slug].tsx @@ -119,6 +119,26 @@ function BlogPostPage(props: any) { ) } + const toc = props.blog.toc && ( + +
    + + {props.blog.tags.map((tag: string) => { + return {tag} + })} + +
    +
    + Table of contents + +
    + {props.blog.toc.content} +
    +
    +
    +
    + ) + return ( <>
    -
    +
    -
    -
    +
    +
    @@ -174,7 +194,7 @@ function BlogPostPage(props: any) { {props.blog.title} {author && ( -
    +
    {author.author_image_url && ( @@ -195,8 +215,8 @@ function BlogPostPage(props: any) {
    -
    -
    +
    +
    {props.blog.thumb && ( )} +
    {toc}
    {content}
    -
    +
    - - {props.blog.tags.map((tag: string) => { - return {tag} - })} - - {props.blog.toc && ( -
    - Table of contents - -
    - {props.blog.toc.content} -
    -
    -
    - )} +
    {toc}
    Related articles @@ -259,7 +266,7 @@ function BlogPostPage(props: any) {
    -
    +
    {props.prevPost && }
    {props.nextPost && (