-
Notifications
You must be signed in to change notification settings - Fork 48
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
Port /blog
to App router; add blog preview cards [#134]
#1059
base: master
Are you sure you want to change the base?
Conversation
131c645
to
e3d671d
Compare
e3d671d
to
94cae8d
Compare
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.
A couple of comments while trying out the PR. I didn't do a thorough comparison of pages as I think others have done so.
94cae8d
to
a960935
Compare
Deletes old Pages Router blog files, as well as displayMarkdown component.
a960935
to
9e5c3bb
Compare
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 only did a quick review in the test app, I didn't dig into specifics. Really love the new layout of the blog page!
I only flagged a weird behavior in loading images when redirecting from the main /blog
page to the most recent blog post.
const redirectTo = mostRecentPost | ||
? `/blog/${mostRecentPost.blogUrlName}` | ||
: `/404`; | ||
|
||
redirect(redirectTo); |
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 images of the most recent blog fail to load when going to /blog, but load fine at /blog/2024-10-22-oropouche-analysis-and-resources
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.
yeah, i see that.
seems to be because the image URLs are relative to /blog
(i.e., img/foo.png
, not /blog/img/foo.png
), maybe? The images are showing as 404 and the HTTP request was GET /img/oropouche_host_view.png
.
oddly, it works fine on localhost... I will dig into the redirect()
API and see if I need to do something different, but an initial fix might be tweaking the image URLs in the Oropouche post.
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.
So, yeah, this is because of how the redirect()
API works, apparently.
I think I'm going to take this as the push from the universe to move ahead with converting the front page to be the five most recent blog posts, which will require some additional refactoring in this PR.
@@ -63,7 +64,7 @@ | |||
"luxon": "^3.4.4", | |||
"make-fetch-happen": "^11.1.1", | |||
"mapbox-gl": "^3.2.0", | |||
"marked": "^0.7.0", | |||
"marked": "^14.1.3", |
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.
nit
update marked from 0.7 to 14.1.3
What an upgrade! I'm sure there was a reason for this but it's hard to tell from the commit message. Was there a function that wasn't available in the older version?
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 primary reason was I needed to update it off 0.7 to get typing support, and so I figured I might as well update it to "current".
FWIW, 0.7 is "only" five years old — the package versions fairly aggressively, for whatever reason.
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.
Makes sense!
// Scans the ./static-site/content/blog directory for .md files and | ||
// returns a chronologically-sorted array of posts, each with some | ||
// basic metadata and the raw (unsanitized) markdown contents. | ||
export function getBlogPosts(): BlogPost[] { |
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.
There are two functions that have duplicated JS and TS versions:
- getBlogPosts
- static-site/src/util/blogPosts.js
- static-site/app/blog/utils.ts
- parseMarkdown
- static-site/app/blog/parseMarkdown.ts
- static-site/src/util/parseMarkdown.js
I understand that the JS versions are still used by scripts/generate-blog-feeds.js
. Is there a plan to deduplicate these 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.
I could convert scripts/generate-blog-feeds
to TS — which would allow the old getBlogPosts()
to be removed — but it felt out of scope of the issue.
The old parseMarkdown()
is also used in static-site/src/components/sourceInfoHeading.jsx
, so that needs both community and groups (at least) to be converted over before it can be removed.
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.
Thanks for the explanation. I still think it'd be useful to add a small comment at the "deprecated" JS file indicating that it's been ported over to TS. Otherwise I will keep asking for clarification about these duplicates in PR reviews.
Description of proposed changes
This ports the
/blog
and/blog/[id]
pages to App Router. It also adds metadata to blog posts, including OpenGraph tags, to support preview cards. Finally, it updates themarked
Markdown parser to the current release, in order to get type support, and adds the@types/sanitize-html
dev dependency to provide type support forsanitize-html
.Note that this code is on top of, and includes, the changes from #1032; when that is merged, I will rebase this on top of it.This is rebased and ready to review.Related issue(s)
static-site
from Pages Router to App Router #1052Checklist