Closed jsonbecker closed 10 months ago
Note this is untested, but should be easy to confirm.
Flagging for @svendahlstrand since he may want to discuss with Manton standardizing this a bit more. It's coming up a lot in the forums as an ask from folks who definitely do not feel comfortable editing templates.
Thanks. Will look at this in more detail tonight. Is there a UI for excluding categories I’ve overlooked somewhere? Or are you telling people to modify the config? —Matt LangfordMattLangford.comOn Dec 26, 2023, at 2:56 PM, Jason Becker @.***> wrote: I see this come up repeatedly in the forums. Most often, folks tell me they're using this theme. I want to point to how to do this in case someone else wants to add this to more Micro.blog themes.
This change addresses the need by:
Adds a check for site paramaters for archive_excluded_categories and index_excluded_categories. When present, returns only pages that are not on those lists.
You can view, comment on, or merge this pull request online at: https://github.com/MattSLangford/Tiny-Theme-for-Micro.blog/pull/7
Commit Summary
6f0c64f Configurable post exclusions by category
File Changes (2 files)
M
layouts/_default/list.archivehtml.html
(6)
M
layouts/index.html
(8)
Patch Links:
https://github.com/MattSLangford/Tiny-Theme-for-Micro.blog/pull/7.patch https://github.com/MattSLangford/Tiny-Theme-for-Micro.blog/pull/7.diff
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
I haven't tried this yet, but looks cool. Maybe the config could be added to plugin.json fields so it doesn't need a custom config JSON file?
Thanks. Will look at this in more detail tonight. Is there a UI for excluding categories I’ve overlooked somewhere? Or are you telling people to modify the config?
At the moment, the idea is to use the site config and have people add categories there. However, since most folks will install this as a plug in, there's probably a way to use Micro.blog's plugin structure to have two fields for this. The only thing I'm unsure of is how to supply a list/array to plug-ins versus just text. You might have to do something like recommend comma-separated categories in a text field and then do {{ split param "," }}
to get an array of category names from the configuration field.
I haven't tried this yet, but looks cool. Maybe the config could be added to plugin.json fields so it doesn't need a custom config JSON file?
That would be cool-- this would be a good example of an array type being useful versus a text field, but creating a form where you can add and remove multiple elements is not a lot of fun, I'm sure. The alternative could be that MB has the infrastructure to do what I suggested above-- a field type of collection
could also have a parameter in the plug in for delimiter
and the Micro.blog can process a text field to split on the delimiter and return a collection to work with.
Cool idea! As categories are known, maybe we could just show them in a select
element with the multiple
attribute set? Something like this:
<label>
Show these categories on my homepage:
<select name="categories" multiple size="6">
<option value="notes">Notes</option>
<option value="swedish">Swedish</option>
<option value="writing">Writing</option>
<option value="then">Then</option>
<option value="projects">Projects</option>
</select>
</label>
Or just use checkboxes. That might be more accessible and easy to use, but a little more work to implement.
I like this. A generic array would be more flexible but a list of categories seems very common. We could have a type = "category" for the field.
I went ahead and merged this. Gonna update the version today as well.
Well, I had to revert back to previous version. Broke a couple blogs quickly. I'll have to dig into it more when I have some time, but the error had to do with index.html:6:30
which is part of this commit.
Hrm. Might be .Params.categories
? I don't have a great local setup at the moment to test.
Based on this PR https://github.com/microdotblog/theme-primrose/pull/4 maybe the issue is the use of .Site.Pages
instead of just .Pages
. I still haven't had chance to test locally.
@jsonbecker I have not been able to get this to work. Have you had any success locally?
This change addresses the need by:
archive_excluded_categories
andindex_excluded_categories
.