-
Notifications
You must be signed in to change notification settings - Fork 29
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
Build the Community section for new homepages #6096
Conversation
link: post.URL, // string | ||
image: post.featured_image // ?? these are always '', might need to grab attached image instead | ||
url: post.URL, // string | ||
imageSrc: post.featured_image // ?? these are always '', might need to grab attached image instead |
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.
I'll double check with Sean if he prefers a placeholder image for blog posts that don't have a featured_image
. All of the most recent blogs posts do not include one, as seen in the blog section of PFE's homepage: https://www.zooniverse.org
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.
This SubHeading component previously was unique to the root About page, but the same style is used in the signed-out homepage design, so I moved it to the shared components file in lib-content.
import dayjs from 'dayjs' | ||
import relativeTime from 'dayjs/plugin/relativeTime' | ||
dayjs.extend(relativeTime) |
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.
PFE's blog feed section uses Moment.js, but that package is now a legacy package.
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.
The monorepo also uses Luxon, so you might want to consolidate on a single package for handling dates.
EDIT: the project app uses Luxon, but I'm not sure that it's actually imported anywhere (just from doing a very quick search for luxon
.)
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.
Was just going to comment the same thing 😆 I think we might be able to simply remove luxon from app-project.
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.
I vaguely remember Roger replacing MomentJS with Luzon, but can't remember which component used it. I assume it got removed or refactored at some point.
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.
PR Review
Packages: app-root, lib-content-pages lib-content
This PR adds the Community section to the home page on app-root.
- New Feature: Community section
- Appears on both signed in and signed out versions of the home page.
- Lists 4x latest articles from Daily Zooniverse, and 4x from the Zooniverse Blog.
Screenshot: the community section with a few articles from Daily Zooniverse
Functionality looks good. 👍
Testing
Tested app-root with macOS + Chrome/FF/Safari on localhost
- Opened https://local.zooniverse.org:3000/
- Scrolled down to view the Community section
- Confirmed that 4 + 4 articles are displayed. ✔️
Additional observation: when the article contents/summaries are being fetched, there's a period where the Community Section actually lists the empty articles. But the empty boxes still have the correct timestamps. Odd.
Screenshot: view of the Community section while in the data fetching process.
Also, tested lib-content with macOS + Chrome using Storybook.
- The Article story looks fine. ✔️
Dev Notes
[rambling][non-blocking]
Code and functionality look good, but if there's one thing that makes me go "huh?" (in a manner where I comically put my hands on my hips, tilt my head, and raise an eyebrow, but not in a manner that blocks this PR) is the way that the the "blog config" is kinda split across two packages.
In app-root
, we have BLOG_FEEDS, which fetches 4 + 4 articles from 2 different blogs, combines them into an 8-article array, then sends them to the Community component in lib-content
, which then splits the 8-article array into 2x 4-article arrays, and assigns them to the 2 different blogs. (Those 2 different blogs also have their own hardcoded URLs and names, which I'd also consider config-ish items.)
I mean, it works, but it's not easy to read outside of this PR (i.e. a dev needs to know to look at both app-root and lib-content to make changes, like increasing the number of articles) nor is it particularly robust (e.g. what if someone edits getBlogPosts() to fetch 5+5 articles and forgets to update lib-content's Community). I imagine we can improve this in a future PR, maybe put the blog data into a config object or something.
Status
Rambling dev note aside, this PR is LGTM 👍
packages/app-root/src/app/page.js
Outdated
@@ -40,7 +40,7 @@ async function getBlogPosts() { | |||
try { | |||
const feeds = await Promise.all(BLOG_FEEDS.map(fetchBlogFeed)) | |||
feeds.forEach(feed => { | |||
posts = posts.concat(feed.slice(0, 3)) | |||
posts = posts.concat(feed.slice(0, 4)) |
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.
[medium suggestion] This number 4's floating around a bit willy-nilly, it might be worth moving it into a config into a constant like NUMBAH_OF_BLOG_POSTS = 4 to match BLOG_FEEDS
</Anchor> | ||
</Box> | ||
<Box gap='small' margin={{ bottom: 'medium' }}> | ||
{blogPosts.slice(0, 4).map(item => ( |
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.
[medium suggestion] There's a magic number 4 here (and a little below at blogPosts.slice(4)
) that might be worth moving into a const
@@ -18,7 +19,7 @@ export default function HomePageContainer({ blogPosts = [] }) { | |||
<p>{user?.login ? 'Signed-in' : 'Signed-out'}</p> | |||
</Box> | |||
)} | |||
<Box pad='medium' align='center'>Number of blog posts: {blogPosts.length}</Box> | |||
<CommunityContainer blogPosts={blogPosts} /> |
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.
[curiosity][query] Actually, I just realised something - why are the blog posts from two different blogs joined together into a single blogPosts array, then split up again in the Community component? Why not send two arrays?
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.
Good catch! It's because I copied the fetching function from PFE where the UI intentionally combines the two feeds by date. However, Sean's design separates the two so each feed could be fetched as separate arrays in app-root. I'll fix that!
Re:
I think this is due to the function used to strip tags and other html entities from the |
Package
app-root
lib-content
Linked Issue and/or Talk Post
Toward: #6024
Toward: #6023
Figma: https://www.figma.com/design/p6laHCEklj9YK79TC1F7NV/Homepages
Describe your changes
luxon
from app-project. See comment: Build the Community section for new homepages #6096 (comment)How to Review
Checklist
PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.
General
yarn panic && yarn bootstrap
ordocker-compose up --build
and FEM works as expected