-
Notifications
You must be signed in to change notification settings - Fork 51
feat(blog): implement new blog layout, custom card component, and markdown data pipeline #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
moshams272
wants to merge
6
commits into
webpack:main
Choose a base branch
from
moshams272:feat/create-blogs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee4fc8c
chore(blogs): add blogs script to get blogs.json
moshams272 d77f23c
chore(blogs): edit blogs.mjs to use local file
moshams272 95faaed
chore(blogs): enhance the blog.mjs and add site.json to sidebar and a…
moshams272 2eb0216
chore(blog): add BlogLayout.jsx and index.modlue.css
moshams272 1bff0d4
chore(blog): add BlogCard.jsx and index.modlue.css
moshams272 94874e3
Clean up comments in index.module.css
moshams272 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,55 @@ | ||
| import styles from './index.module.css'; | ||
|
|
||
| const formatDate = dateString => { | ||
| if (!dateString) return ''; | ||
| const date = new Date(dateString); | ||
| return date.toLocaleDateString('en-GB', { | ||
| day: 'numeric', | ||
| month: 'short', | ||
| year: 'numeric', | ||
| }); | ||
| }; | ||
|
|
||
| export default function BlogCard({ | ||
| slug, | ||
| title, | ||
| date, | ||
| description, | ||
| contributors = [], | ||
| }) { | ||
| return ( | ||
| <div className={styles.card}> | ||
| <div className={styles.decoration}></div> | ||
|
|
||
| <a href={`/blogs/${slug}`} className={styles.mainLink}></a> | ||
|
|
||
| <div className={styles.content}> | ||
| <h5 className={styles.title}>{title || 'Untitled Post'}</h5> | ||
| <p className={styles.description}>{description}</p> | ||
| </div> | ||
|
|
||
| <div className={styles.footer}> | ||
| <div className={styles.avatars}> | ||
| {contributors.map(user => ( | ||
| <a | ||
| key={user} | ||
| href={`https://github.com/${user}`} | ||
| target="_blank" | ||
| className={styles.avatarLink} | ||
| title={user} | ||
| > | ||
| <img | ||
| src={`https://github.com/${user}.png?size=64`} | ||
| alt={user} | ||
| className={styles.avatar} | ||
| /> | ||
| </a> | ||
| ))} | ||
| </div> | ||
|
|
||
| <span className={styles.dot}>•</span> | ||
| <span className={styles.date}>{formatDate(date)}</span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,125 @@ | ||
| @reference "../../../styles/index.css"; | ||
|
|
||
| .card { | ||
| @apply relative | ||
| flex | ||
| flex-col | ||
| h-full | ||
| rounded-xl | ||
| border | ||
| border-neutral-200 | ||
| bg-white | ||
| p-6 | ||
| overflow-hidden | ||
| transition-colors | ||
| duration-150 | ||
| hover:border-blue-300 | ||
| hover:bg-blue-50/40 | ||
| dark:border-neutral-800 | ||
| dark:bg-neutral-900 | ||
| dark:hover:border-blue-400/60 | ||
| dark:hover:bg-blue-950/40; | ||
| } | ||
|
|
||
| .decoration { | ||
| @apply absolute | ||
| -right-8 | ||
| -top-8 | ||
| size-32 | ||
| bg-blue-500 | ||
| opacity-0 | ||
| transition-all | ||
| duration-500 | ||
| translate-x-4 | ||
| -translate-y-4; | ||
|
|
||
| clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%); | ||
| } | ||
|
|
||
| .card:hover .decoration { | ||
| @apply opacity-5 | ||
| dark:opacity-10 | ||
| translate-x-0 | ||
| translate-y-0 | ||
| rotate-12; | ||
| } | ||
|
|
||
| .mainLink { | ||
| @apply absolute | ||
| inset-0 | ||
| z-0 | ||
| focus:outline-none; | ||
| } | ||
|
|
||
| .content { | ||
| @apply flex | ||
| flex-col | ||
| gap-3 | ||
| pb-5 | ||
| pointer-events-none; | ||
| } | ||
|
|
||
| .title { | ||
| @apply m-0 | ||
| text-xl | ||
| font-bold | ||
| leading-tight | ||
| text-neutral-900 | ||
| dark:text-white; | ||
| } | ||
|
|
||
| .description { | ||
| @apply m-0 | ||
| line-clamp-3 | ||
| text-base | ||
| leading-relaxed | ||
| text-neutral-600 | ||
| dark:text-neutral-400; | ||
| } | ||
|
|
||
| .footer { | ||
| @apply mt-auto | ||
| flex | ||
| items-center | ||
| border-t | ||
| border-neutral-100 | ||
| pt-3 | ||
| dark:border-neutral-800/80; | ||
| } | ||
|
|
||
| .avatars { | ||
| @apply flex | ||
| items-center | ||
| -space-x-2; | ||
| } | ||
|
|
||
| .avatarLink { | ||
| @apply relative | ||
| z-10 | ||
| transition-transform | ||
| hover:-translate-y-1; | ||
| } | ||
|
|
||
| .avatar { | ||
| @apply size-8 | ||
| rounded-full | ||
| border-2 | ||
| border-white | ||
| bg-neutral-100 | ||
| dark:border-neutral-900 | ||
| dark:bg-neutral-800; | ||
| } | ||
|
|
||
| .dot { | ||
| @apply mx-3 | ||
| text-neutral-300 | ||
| dark:text-neutral-600; | ||
| } | ||
|
|
||
| .date { | ||
| @apply tabular-nums | ||
| text-sm | ||
| font-medium | ||
| text-neutral-500 | ||
| dark:text-neutral-400; | ||
| } |
This file contains hidden or 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 hidden or 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,40 @@ | ||
| import PartialArticle from '../PartialArticle/index.jsx'; | ||
| import BlogCard from '../../components/Blog/Card/index.jsx'; | ||
| import blogsData from '../../generated/blogs.json'; | ||
| import styles from './index.module.css'; | ||
|
|
||
| /** | ||
| * Blogs page layout. Lists all Webpack blog posts in a grid, | ||
| * wrapped inside the PartialArticle shell to preserve the Sidebar and Navbar. | ||
| * | ||
| * @param {{ metadata: object }} props | ||
| */ | ||
| export default function BlogLayout({ metadata }) { | ||
| return ( | ||
| <PartialArticle metadata={metadata}> | ||
| <section className={styles.blogSection}> | ||
| <div className={styles.container}> | ||
| <header className={styles.header}> | ||
| <h1 className={styles.mainTitle}>Webpack Blog</h1> | ||
| <p className={styles.subtitle}> | ||
| Latest news, updates, and deep dives from the Webpack team and | ||
| community. | ||
| </p> | ||
| </header> | ||
| <main className={styles.grid}> | ||
| {blogsData.map(post => ( | ||
| <BlogCard | ||
| key={post.slug} | ||
| slug={post.slug} | ||
| title={post.title} | ||
| date={post.date} | ||
| description={post.description} | ||
| contributors={post.contributors} | ||
| /> | ||
| ))} | ||
| </main> | ||
| </div> | ||
| </section> | ||
| </PartialArticle> | ||
| ); | ||
| } |
This file contains hidden or 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,47 @@ | ||
| @reference "../../styles/index.css"; | ||
|
|
||
| .blogSection { | ||
| @apply bg-white | ||
| py-16 | ||
| lg:py-20 | ||
| dark:bg-neutral-950; | ||
| } | ||
|
|
||
| .container { | ||
| @apply mx-auto | ||
| max-w-7xl | ||
| px-6; | ||
| } | ||
|
|
||
| .header { | ||
| @apply mb-12 | ||
| border-b | ||
| border-neutral-200 | ||
| pb-8 | ||
| text-center | ||
| dark:border-neutral-800; | ||
| } | ||
|
|
||
| .mainTitle { | ||
| @apply mb-3 | ||
| text-3xl | ||
| font-bold | ||
| text-neutral-900 | ||
| lg:text-4xl | ||
| dark:text-white; | ||
| } | ||
|
|
||
| .subtitle { | ||
| @apply mx-auto | ||
| max-w-2xl | ||
| text-lg | ||
| text-neutral-600 | ||
| dark:text-neutral-400; | ||
| } | ||
|
|
||
| .grid { | ||
| @apply grid | ||
| gap-6 | ||
| sm:grid-cols-2 | ||
| lg:grid-cols-3; | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split this into a few different files to make things clearer, such as:
Blog/PostCardBlog/Cover(the post image)Blog/Byline(the author info)