Skip to content
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

#184: Use Volt for blog #206

Merged
merged 32 commits into from
Jul 13, 2024
Merged

Conversation

JSn1nj4
Copy link
Owner

@JSn1nj4 JSn1nj4 commented Jul 13, 2024

The blog is now rendered using Volt components. This was done to make pagination nicer, and to prep for adding search later.

Clicking into an individual blog post also uses Volt now.


Resolves #184

JSn1nj4 and others added 30 commits July 5, 2024 00:10
This also strips down most of the post indexing stuff from original version, so need to figure out a better way to add the same filters back in.
Also added optional wire navigation to a number of elements—AND DISCOVERED A BUG.
NOT FIXED YET. Just used a dummy project to smoke out some issues with how testing changed recently.
Was very outdated, including having some vars that didn't exist anymore in the new example file, missing some that were added, and missing some renames.
Add a Livewire and Volt helpers for quickly checking that components can mount.

Also discovering there's something wrong with finding the database. Sometimes it's there, sometimes the necessary tables are there...other times, not.
Don't try to create models before tests start, otherwise the DB connection won't be ready.
For some reason, Pennant's table isn't available before tests are run.

To get around this, Pennant feature storage will use the array driver as suggested here:
https://laravel.com/docs/11.x/pennant#store-configuration
Allow manually setting a created post 'published' to check that this component can render (duh, it can't if the post isn't published).
Was complaining about not being able to drop indexes because they didn't exist, meaning it was happening when running migration `down()` methods.

Now these migrations conditionally check if the indexes exist before trying to drop them.
This will be helpful for locating HTML in tests...maybe.
Tests work, but the 1 test in BlogPostTest is flaky.

I tried explicitly setting the `publish` and `published_at` states for the 1 post I'm passing in to guarantee it'll be published, but it's not working...

And it's literally just for this 1 test.

In BlogIndexTest, it seems to be consistent...or is it?
I undid some bad factory design from a while ago to hopefully fix this, but overriding these fields still appears to not work.

Why...?
Thinking it was a combination of things:
- using '->afterMaking()' directly in the factory instead of '->state()'
- passing static closures to methods that use closure binding under the hood

Had some help from Zach smoking this out and refactoring a bit. Now:
- Generated posts are unpublished by default
- The randomness idea is contained in a dedicated factory method for when I definitely want it
- Setting 'published' explicitly is now its own factory method

Co-authored-by: The Zach <[email protected]>
Need to customize 404 message:
- shouldn't use 'no query results for model'
- shouldn't include the class name
- probably should say page or post not found
Before I was loading the old GA component—which is fine for Blade, but it doesn't work for Livewire due to slots replacing stacks.

So GA will now be configured in a Volt component as well.

I think some of the leftover vanilla GA stuff will need to become Alpine components.
Restructured a bit and fixed a super annoying "expression not defined" issue with existing Alpine stuff.

1. The cookie popup is now its own partial. This makes far more sense because it's not REALLY part of the whole Google Analytics thing. It just hooks into part of it.

2. Google Analytics is a Volt component now, which means Alpine is pulled in directly. There's no need to load Alpine separately anymore.

3. A separate Alpine global file actually does exist now, for if it's ever needed. It shouldn't be, but it's there just in case.

4. All the old GA and popup stuff is removed since both are set up different ways now.

5. The listener for that custom event is now collocated with the actual handler. Don't know why I didn't do this before, it makes FAR more sense this way.
Since we're back on this train...
Forgot I allow the details of the failure through outside of prod.
@JSn1nj4 JSn1nj4 self-assigned this Jul 13, 2024
@JSn1nj4 JSn1nj4 added the enhancement New feature or request label Jul 13, 2024
@JSn1nj4 JSn1nj4 changed the title #184: Use Volt for blog pagination #184: Use Volt for blog Jul 13, 2024
@JSn1nj4 JSn1nj4 merged commit a7ab85b into develop Jul 13, 2024
@JSn1nj4 JSn1nj4 deleted the feature/184-Use-Volt-for-blog-pagination branch July 13, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Livewire/Volt for blog pagination
1 participant