-
Notifications
You must be signed in to change notification settings - Fork 609
Description
@PhrozenByte don't feel the need to read or answer this all at once. I just didn't see the point of making multiple issues on very similar topics.
I've been laser focused on updating an old theme this week (Freelancer). It's gonna be pretty good. 😉
But, in the process I've had a few issues I wanted to discuss, especially considering the pico-theme.yml standard (and our as far as I can tell lack of documentation on it). (Okay, I lied here, it was like one question. 😂)
I've had a bunch of random thoughts and questions related to theming as I've been going, but I figured I'd hold them until the end and see what I couldn't just answer myself.
This is just meant to be a thread for a general discussion, not a singular issue. So, let's get into it.
- The
pico-theme.yml's meta-headers section doesn't seem to support arrays for having multiple levels of depth. Not sure whether this is an oversight or by design. The use case I'd describe here would be:
I have several meta-headers named portfolio_title, portfolio_divider, portfolio_nav and portfolio_disabled.
These could be written:
Portfolio Title: Recent Projects
Portfolio Divider: clock
Portfolio Nav: Projects
Portfolio Disabled: false
But I feel they'd look better as:
Portfolio:
Title: Recent Projects
Divider: clock
Nav: Projects
Disabled: false
It's fine if you've decided you just don't want Pico to have multi-level arrays of metadata, but I have been using them to simplify the YML on my themes for quite a while, lol. 😂
What are your thoughts on this? Is it an idea you absolutely hate or might it have potential?
Obviously in the meantime I can still accomplish this without registering them in pico_theme.yml (that's how I've been developing it anyway), they'll just have mandatory lower-case names like portfolio > title.
On a related side note, I almost opened this issue a few days ago to discuss how weird and inconsistent it feels when, if you don't register meta headers, they behave somewhat opposite of the built-in ones:
We typically write the meta headers with the first letter capitalized. When you do this, it then only presents itself as lowercase in Twig (eg Title becomes title). But if you have an unregistered custom header, the opposite becomes true. You write it with the first letter capitalized and it is only available the way you wrote it (Image stays Image).
I know why this is the case... it just feels odd and like it could be something of a trap for new users.
- I've noticed that on some of my old themes (that I haven't got around to fixing yet), whitespace has started being removed by Twig. This has led to text beingcrushedtogether in some cases. Just curious if you knew when and why this behavior changed (besides the obvious "sometime between Pico 1 and 2 😂).
- Is Twig's
rawfilter generally "safe" to use in Pico? I've been using it on this project more than I intended too because if I do anything to manipulate strings before printing them they become escaped, which doesn't work so well for HTML tags. 😅
It doesn't really seem like an issue considering our usual attitude toward security (that any access to Pico's files is the same level of security, and if someone had access to put something malicious in the markdown anyway, then they could probably already do a lot worse without caring about the Twig template, etc).
- Pico's
markdownfilter doesn't seem to throw errors. This is a very different behavior to Twig's built in filters (which complain. A lot.). I accidentally fed it an array a couple times and it just silently fails. Compare this to Twig throwing an "Array to string conversion" notice every time I accidentally forget tojson_encodemy debug code (🤦🏻♀️), and I just feel like it should say something when you do it wrong. No idea if Pico's other filters are like this or not.
Do you think they should print errors for debugging?
- It seems like having a
_meta.mdfile is now an "officially endorsed" concept (at least in the docs). A lot of themes (Freelancer included) ignoreindex.mdin favor of giving a custom front-page (or single-page) experience.
I like the idea of having theme-related/site-wide metadata in _meta.md (and it's what I've used this time), however, it does leave an awkward index.md-sized hole to be filled. 😉
Specifically, I mean you still require an empty index.md in this case, even if you're not using it, both for Pico's content folder detection and for preventing 404's (with the content dir manually specified in config.yml).
I guess this is mostly an opinion thing, but it leaves me wondering what approach is better in this case. If I use index.md for the metadata, it's at least used for something. The instructions wouldn't need a step that says "make sure you have an index.md, even if it's empty". What do you think? Would you rather themes suggest a blank index or that they forgo _meta.md in favor of sticking everything in index.md?
- 404-ing on
_meta.mdbehaves weird.
So, this theme rewrite is heavily dependent on _meta.md containing all its variables (don't worry, I've hard-coded defaults, so it all looks very professional even with an empty _meta.md 😉). I decided to test that Pico supposedly denies access to _ files, and I discovered an odd behavior. When it 404's on trying to access _meta.md... it also denies access to all the metadata I was accessing on _meta.md, causing my very customized site to revert to the demo data I've included.
Presumably this is happening because there's a shortcut somewhere in Pico that goes "I need to access this page. Oh, good, I'm already on it, I'll just look at current_page instead." Except its current page has been redirected to the 404 page. 🤦🏻♀️
Just kind of an odd quirk. I don't need it fixed or anything, just thought I'd bring it to your attention. 😂
- Kind of surprised that using
pages.pageidinstead ofpages["pageid"]still works. I'm assuming this is still just a legacy, compatibility behavior, since I remember you telling me a long time ago that it was preferred to usepages["pageid"]instead. I guess that's all, it was just kind of a "Huh... neat" moment. 🤷🏻♀️
- This one should probably be a separate discussion entirely. Do you have any good suggestions for maintaining a large patch set against an upstream? The Twig bits I've written for Freelancer are exhaustively extensive. I've spent over a week on it now (while the Themes Gallery project hangs in limbo 😒). It just keeps going, lol. I need to stop adding things to it.
The original theme is written with Bootstrap, in SCSS and PUG. Since the Pico port is based on the compiled version, I can't exactly just grab the original repo as an upstream (though, maybe I could potentially pull from their compiled dist folder somehow).
At the moment, I plan to remove the upstream on my existing port (it was based on an out-of-date Jekyll version), and just replace the entire repo with the new version and sort this out later.
For future updates of Bootstrap and Freelancer though, it'd be nice to have a solution in place to be able to bring the changes forward without essentially starting from scratch every time.
At the moment, the best idea I'd have would be to diff the old and new Freelancer versions and simply use that to get a rough idea of what changed between versions. Or, you know, see if I could somehow make a patch file based on the diff between my version and theirs, but I think the changes might be too extensive for that (or at the very least, I might have to merge all my includes back into one mega-template). Either way, I don't see it being as easy as "fetch and merge upstream". 😩
So, if there's a fairly obvious solution you think I should look into, let me know. Not looking for a full solution, just a nudge in the right direction if you have any ideas. 😅
Alright, this has gone on long enough. I'm so ready to move on from this theme, but I keep finding one more thing to do.
And I promise the next one will be a "regular" theme. This one's just been needing some attention. 😉