Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Add Blog posts, components, and local caching system#57

Merged
katjuell merged 21 commits intomainfrom
kjuell/port-blogs
Apr 6, 2022
Merged

Add Blog posts, components, and local caching system#57
katjuell merged 21 commits intomainfrom
kjuell/port-blogs

Conversation

@katjuell
Copy link
Contributor

@katjuell katjuell commented Mar 25, 2022

Closes #32 and resolves #33 by adding all blog records and blog components.

Also adds a local file and slug caching system, for a few reasons: it's a good idea to minimize page compute and page props size. By having a local file directory cache and slug cache, we can ensure that the values we need to build our pages are pre-computed. We can also ensure that we don't pass massive globs of data as page props.

An important piece of inspiration for this was also this discussion about the known limitations in passing data between staticPaths and staticProps, particularly this comment and this related repo.

There were a few tricky bits with this workflow:

  • As you will notice, I moved the liveblogs directly into the blogposts content directory. They will now be served from /blog/<conference-directory>/<slug>.
  • Our file parsing workflow needs to respect nested file locations, and directory locations with year numbering schemes (2020, 2021, etc). Those values cannot be present in the slugs, however.
  • We also need to respect cases where specified slugs in the frontmatter do not align with the file name.

I have addressed these issues in how the slugs get set, and have made pulling the correct file path name a (hopefully) simple, object-based exercise of files.records[fileSlug].filePath (with files being the cached JSON with our complete record info).

IMPORTANT: Static builds will not work with this workflow. This is because we still need to work on #56, which was a big enough task for me to offload it to another issue. I'd like to get this work in first, so this will block that work until merged. Likewise, the cache workflow has not been added to our build scripts.

Also, podcasts will not work. Different issue.

To Test

  • Ensure you have the specified local dependencies
  • Run yarn dev and navigate to any of the existing terms pages (should all work) and any blog post. Some of them will not work thanks to Migrate all embedded blog styles in MD to work with new parsing pipeline #56 but enough do that you should be able to get a sense: /blog/go/a-go-guide-to-syscalls, /blog/integration-testing, etc.
  • Also try out cases where the slugs do not match the file names: /blog/software-engineer-career-ladder for example.

@katjuell katjuell added the team/content-platform Content Platform Team related tickets. label Mar 25, 2022
@katjuell katjuell added this to the Phase 1 - Sprint 1 milestone Mar 25, 2022
@katjuell katjuell self-assigned this Mar 25, 2022
@katjuell katjuell requested a review from bretthayes March 25, 2022 16:06
@katjuell
Copy link
Contributor Author

katjuell commented Mar 29, 2022

@bretthayes this should be error-free now following #55 !

Copy link
Contributor

@bretthayes bretthayes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phew! What a port! My machine struggled to load the Files Changed tab lol.
Awesome work on this!! 🚀 Left a few comments on some small things below.

@bretthayes
Copy link
Contributor

Btw, you might have to reword this in your PR description or it'll close that ticket.
Screen Shot 2022-04-05 at 3 40 35 PM

@katjuell
Copy link
Contributor Author

katjuell commented Apr 6, 2022

@bretthayes added some error handling in the templates. You can test by removing either of the cache files after the initial build — you should be redirected to 404s in both cases

@katjuell katjuell requested a review from bretthayes April 6, 2022 18:25
Copy link
Contributor

@bretthayes bretthayes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful! Looks good to me!

@katjuell
Copy link
Contributor Author

katjuell commented Apr 6, 2022

w00t! Thanks for the massive review here

@katjuell katjuell merged commit e996a39 into main Apr 6, 2022
@katjuell katjuell deleted the kjuell/port-blogs branch April 6, 2022 18:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team/content-platform Content Platform Team related tickets.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Port blog components Port blog posts

2 participants