-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: updated recent blog posts UI (#543)
Co-authored-by: Tushar Mathur <[email protected]>
- Loading branch information
1 parent
61ad510
commit 112f3db
Showing
7 changed files
with
122 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {PluginOptions, BlogContent} from "@docusaurus/plugin-content-blog" | ||
import {LoadContext, PluginContentLoadedActions} from "@docusaurus/types" | ||
|
||
import * as blogPluginExports from "@docusaurus/plugin-content-blog" | ||
const defaultBlogPlugin = blogPluginExports.default | ||
|
||
async function blogPluginEnhanced(context: LoadContext, options: PluginOptions) { | ||
const blogPluginInstance = await defaultBlogPlugin(context, options) | ||
|
||
return { | ||
...blogPluginInstance, | ||
async contentLoaded({content, actions}: {content: BlogContent; actions: PluginContentLoadedActions}) { | ||
if (blogPluginInstance.contentLoaded) { | ||
await blogPluginInstance.contentLoaded({content, actions}) | ||
} | ||
|
||
const {setGlobalData} = actions | ||
const recentBlogPostsLimit = 10 | ||
|
||
const recentBlogPosts = [...content.blogPosts].splice(0, recentBlogPostsLimit) | ||
const recentBlogPostsMetadata = recentBlogPosts.map((blog) => { | ||
const { | ||
date, | ||
title, | ||
frontMatter: {description}, | ||
authors, | ||
permalink, | ||
} = blog.metadata | ||
|
||
return { | ||
date, | ||
title, | ||
description, | ||
authors, | ||
permalink, | ||
} | ||
}) | ||
setGlobalData({recentBlogPostsMetadata}) | ||
}, | ||
} | ||
} | ||
|
||
module.exports = { | ||
...blogPluginExports, | ||
default: blogPluginEnhanced, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from "react" | ||
import Link from "@docusaurus/Link" | ||
import clsx from "clsx" | ||
import {BlogAuthor} from "@site/src/theme/BlogAuthor" | ||
import {Author} from "@docusaurus/plugin-content-blog" | ||
|
||
export interface BlogListItemProps { | ||
date: string | ||
title: string | ||
description: string | ||
authors: Author[] | ||
permalink: string | ||
} | ||
|
||
const BlogListItem: React.FC<BlogListItemProps> = ({date, title, description, authors, permalink}) => { | ||
return ( | ||
<Link to={permalink} className="flex flex-col overflow-hidden !text-black !no-underline"> | ||
<div className="flex flex-col flex-1 p-3 md:py-12 md:px-6 gap-2 md:gap-3 border border-solid border-tailCall-border-light-400 hover:border-tailCall-border-dark-100 rounded-lg md:rounded-md"> | ||
<span className="hidden md:flex text-content-mini text-black"> | ||
{new Date(date).toLocaleDateString("en-US", { | ||
month: "long", | ||
day: "numeric", | ||
year: "numeric", | ||
})} | ||
</span> | ||
<div className="flex flex-col flex-1 gap-1 md:gap-2"> | ||
<span className={clsx("text-title-small line-clamp-2")}>{title}</span> | ||
<span className="flex-1 text-content-tiny md:text-content-small line-clamp-1 md:line-clamp-3 text-tailCall-light-600 blog-post-content-desc"> | ||
{description} | ||
</span> | ||
</div> | ||
{authors[0] && <BlogAuthor author={authors[0]} containerClassName="mt-auto" />} | ||
</div> | ||
</Link> | ||
) | ||
} | ||
|
||
export default BlogListItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters