From f5bdc00d241242e1b3db68abf591a2867b33bd9c Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Fri, 5 Nov 2021 08:54:43 +0800 Subject: [PATCH] chore: update blog layouts --- www/components/Blog/BlogHeader.tsx | 10 +- www/components/Blog/BlogListItem.tsx | 104 ++++++++++-------- www/lib/helpers.tsx | 4 + www/pages/blog.tsx | 41 ++++--- .../blog/[year]/[month]/[day]/[slug].tsx | 100 +++++++++++++---- www/pages/case-studies/[slug].tsx | 1 + www/types/post.ts | 1 + 7 files changed, 175 insertions(+), 86 deletions(-) diff --git a/www/components/Blog/BlogHeader.tsx b/www/components/Blog/BlogHeader.tsx index 0e6f0432c26..d4b37e91387 100644 --- a/www/components/Blog/BlogHeader.tsx +++ b/www/components/Blog/BlogHeader.tsx @@ -7,10 +7,12 @@ interface Props { export default function BlogHeader({ title }: Props) { return ( -
-
-
- {title} +
+
+
+ + {title} +
diff --git a/www/components/Blog/BlogListItem.tsx b/www/components/Blog/BlogListItem.tsx index 9df111a58f3..be3280947ad 100644 --- a/www/components/Blog/BlogListItem.tsx +++ b/www/components/Blog/BlogListItem.tsx @@ -2,6 +2,7 @@ import { Badge, Space, Typography } from '@supabase/ui' import authors from 'lib/authors.json' import Link from 'next/link' import React from 'react' +import { capitalize } from '~/lib/helpers' import PostTypes from '~/types/post' interface Props { @@ -11,62 +12,71 @@ interface Props { const BlogListItem = ({ blog }: Props) => { // @ts-ignore const author = blog.author ? authors[blog.author] : authors['supabase'] + + console.log('blog', blog) return ( -
-
- - - +
+ +
+ +
+ {blog.tags && + blog.tags.map((tag: string) => ( + +
+ {capitalize(tag.replace('-', ' '))} +
+ + ))} +
- {author && ( -
- - {author.author_image_url && ( - - )} - - {author.author} - - {author.position} - - - -
- )} - {/* + + {blog.description} + + + {/* {blog.content.substring(0, 210) + '...'} Read more */} - - - -
+
+
) } diff --git a/www/lib/helpers.tsx b/www/lib/helpers.tsx index c07c3c10278..33b8fb8ed3f 100644 --- a/www/lib/helpers.tsx +++ b/www/lib/helpers.tsx @@ -7,3 +7,7 @@ export const generateReadingTime = (text: string) => { const readTime = Math.ceil(minutes) return `${readTime} minute read` } + +export function capitalize(word: string) { + return word[0].toUpperCase() + word.substring(1).toLowerCase() +} diff --git a/www/pages/blog.tsx b/www/pages/blog.tsx index 7eff486f820..70dc949deb8 100644 --- a/www/pages/blog.tsx +++ b/www/pages/blog.tsx @@ -63,19 +63,20 @@ function Blog(props: any) { -
+ +
-
- Latests posts -
- {props.blogs.slice(0, 2).map((blog: any, idx: any) => { - return FeaturedThumb(blog) - })} -
+
+ Latests post + {props.blogs.slice(0, 1).map((blog: any, idx: any) => { + return FeaturedThumb(blog) + })}
+
+
-
+
More posts from the team @@ -100,10 +101,15 @@ function Blog(props: any) {
-
+
+ +
+
{/*
    */} {blogs.map((blog: PostTypes, idx: number) => ( - +
    + +
    ))} {/*
*/}
{' '} @@ -120,14 +126,14 @@ function FeaturedThumb(blog: PostTypes) { const author = blog.author ? authors[blog.author] : authors['supabase'] return ( -
+
- + - +
{blog.date} @@ -136,16 +142,19 @@ function FeaturedThumb(blog: PostTypes) { - + {blog.title} + + {blog.description} + {blog.tags && blog.tags.map((tag: string) => ( - + {tag} diff --git a/www/pages/blog/[year]/[month]/[day]/[slug].tsx b/www/pages/blog/[year]/[month]/[day]/[slug].tsx index b2eeeeac618..d5f8f4300d3 100644 --- a/www/pages/blog/[year]/[month]/[day]/[slug].tsx +++ b/www/pages/blog/[year]/[month]/[day]/[slug].tsx @@ -1,4 +1,4 @@ -import { Badge, Card, Divider, IconFile, Space, Typography } from '@supabase/ui' +import { Badge, Card, Divider, IconChevronLeft, IconFile, Space, Typography } from '@supabase/ui' import matter from 'gray-matter' import authors from 'lib/authors.json' import hydrate from 'next-mdx-remote/hydrate' @@ -176,33 +176,44 @@ function BlogPostPage(props: any) { }} /> -
-
-
-
-
- - - - - View more posts - - - - - +
+
+
+ {/* Back button */} + + + + Back + + +
+
+ {/* Title and description */} +
+
+ Blog post + {props.blog.title} +
{props.blog.date} • {generateReadingTime(props.blog.content.renderedOutput)} - - {props.blog.title} +
{author && (
{author.author_image_url && ( - + )} {author.author} @@ -215,9 +226,60 @@ function BlogPostPage(props: any) { )}
+
+ {/* Content */} +
+ {props.blog.thumb && ( + + )} +
+ {content} +
+
+ {/* Sidebar */} +
+
{toc}
+
+ + Related articles + + + {props.relatedPosts.map((post: any) => ( + +
+ + + + + {post.title} + + + + +
+ + ))} + +
+ + + View all posts + + +
+ +
+
+
+
+
diff --git a/www/pages/case-studies/[slug].tsx b/www/pages/case-studies/[slug].tsx index 1f334466e6f..511d8fe09f4 100644 --- a/www/pages/case-studies/[slug].tsx +++ b/www/pages/case-studies/[slug].tsx @@ -169,6 +169,7 @@ function BlogPostPage(props: any) { >
+ {/* Back button */} diff --git a/www/types/post.ts b/www/types/post.ts index be202e15d1c..47d9523aa21 100644 --- a/www/types/post.ts +++ b/www/types/post.ts @@ -14,6 +14,7 @@ type PostTypes = { thumb: string image: string readingTime: string + description: string url: string tags: [] logo?: string