The goal of this project was to display the text “Hello World!” at https://hello.zalgorithm.com. It somehow morphed into creating a Remix client application that consumes a headless WordPress site. I’ve been working without much of a plan. That’s starting to show in the application’s URL structure.
Tag: wordpress
Using the previousPost and nextPost Fields
Yesterday I made a WPGraphQL Adjacent Posts plugin. It adds fields that can be used for obtaining adjacent posts to the WPGraphQL Post type schema. I’m going to use those fields to add previous/next navigation to the Remix app.
Previous and Next Post Links (take two)
I made a start on that yesterday, but stopped when I realized I didn’t understand what I was doing. Starting in the middle of a task without much of a plan might be an example of a “zalgorithm.” The trick is to be willing to go back to the beginning when necessary. I’ll do that now.
Link to the previous and next posts
Last night I found out I can serve images and audio files from a DigitalOcean space. Then I created a bunch of WordPress posts for audio files. Browsing through them got me wanting “previous” and “next” buttons at the bottom of each post.
Featured posts
With pagiation out of the way, it’s time to clean up the home page. Instead of displaying the 5 most recent posts at the top of the page, it’s going to pull in the site’s “featured” posts. I’ll mark posts as featured by giving them a “featured” tag.
Pagination (take five: success!)
I realized the problem I’m having with pagination is that I’m trying to implement page based pagination but WPGraphQL has been optimized for cursor based pagination.
Pagination (take four)
Why do this at all if LLMs can write adequate code and blog posts? The short answer is that they can’t, yet. The longer answer follows from LLM’s lack of understanding and common sense.
Pagination (take three)
Yesterday I added pagination to the app’s Archive route with the useFetcher hook and the fetcher.Form component. This works, but using forms to create navigation elements feels weird. It also adds some complexity to the code:
Pagination (take two)
This works, but it creates ugly URLs: /blog/archive/YXJyYXljb25uZWN0aW9uOjk4. It’s also not a great user interface. It needs to supply more context and ways of skipping around and filtering batches of posts.
Loading More Posts From an Archive Route
Yesterday I added an archive route to the Remix app. Visiting the archive route loads the first 15 posts from the WordPress site. Today I’ll figure out how to load more posts after the initial batch of 15.