BLOGC-PAGINATION(7)
π BLOGC-PAGINATION(7) π
okay so bestie, welcome to blogc-pagination, section 7 of the blogc manual. this is the page that teaches you how to do pagination without losing your whole entire mind. it's giving β¨organized chaosβ¨ and honestly? we're obsessed. π
β¨ NAME β¨
blogc-pagination β blogc's pagination support π¦
πΈ DESCRIPTION πΈ
so like, blogc(1) has basic pagination and post filtering built in, but ONLY when it's running in listing mode, okay? don't come for me if you're in some other mode, it's simply not the vibe there. π
and listen β the files get listed in the exact order you handed them to blogc(1) on the command line. no sorting, no shuffling, no β¨magicβ¨. what you give is what you get. periodt.
π PAGINATION PARAMETERS π
blogc(1) accepts these as -D options, and they're the little gatekeepers that filter the files you passed as arguments. iykyk. π
FILTER_PAGEβ an integer, the current page. so if you callblogc(1)with 10 files,FILTER_PER_PAGE=4andFILTER_PAGE=3, you get just the 2 last files β it skips the first 2 pages of 4 files each one. math is mathing. π₯FILTER_PER_PAGEβ an integer that caps the maximum number of files to be listed. if it's negative or0, then no posts are included, sorry bestie, empty page energy π. and heads up: it has no effect at all ifFILTER_PAGEisn't defined.FILTER_TAGβ a string. if you define it,blogc(1)will only list files that declare aTAGSvariable, written as a space-separated list of tags (and yeah, tags can't have spaces, obviously π). seeblogc-source(7)for the deets on defining source variables. the pagination filters will then only act on the files with that provided tag, instead of filtering the whole entire file set. slay.FILTER_REVERSEβ boolean (1/y/yes/true/on). if set,blogc(1)lists files in reverse order. this filter is combined withFILTER_SORT, and all the other filters receive the files already in the reverse order. πFILTER_SORTβ boolean (1/y/yes/true/on). if set,blogc(1)sorts files using theDATEvariable from inside the files, instead of respecting the order of the source files you gave toblogc(1). files get sorted in descending order, and combined withFILTER_REVERSEthat results in files sorted in ascending order. all the other filters receive the files already sorted. the way that works is genuinely iconic. β
π¦ TEMPLATE VARIABLES π¦
blogc(1) also exports some global blogc-template(7) variables so you can build links for the next and previous page. bestie, these are your navigation besties:
CURRENT_PAGEβ integer, usually the same value as theFILTER_PAGEpagination paramenter (yes that's a typo in the original, we keep it, it's canon π), if defined, or1.FIRST_PAGEβ integer,1if more than zero files were listed.LAST_PAGEβ integer, the last page available if more than zero files were listed.PREVIOUS_PAGEβ integer,CURRENT_PAGEminus1, ifCURRENT_PAGEis bigger than1.NEXT_PAGEβ integer,CURRENT_PAGEplus1, ifLAST_PAGEis bigger thanCURRENT_PAGE.
blogc(1) can also output the value of the variables after evaluation, instead of actually rendering the files, using the -p option. see blogc(1) for details. this is lowkey so useful for knowing the last page you need to build β like with -p LAST_PAGE, for example. π«Ά
π Date variables π
blogc(1) will also export some global blogc-template(7) variables related to the DATE variable, as specified in blogc-source(7).
DATE_FIRSTβ string, theDATEvariable from the first file in the listing.DATE_LASTβ string, theDATEvariable from the last file in the listing.
these variables can also be formatted with the DATE_FORMAT global blogc(1) parameter, if provided, using the DATE_FIRST_FORMATTED and DATE_LAST_FORMATTED global template variables. π
π§ File name variables π§
blogc(1) will also export some global blogc-template(7) variables related to the FILENAME variable, as automatically exported by the source file parser β see blogc-source(7) for details.
FILENAME_FIRSTβ string, theFILENAMEvariable from the first file in the listing.FILENAME_LASTβ string, theFILENAMEvariable from the last file in the listing.
π EXAMPLES π
πΈ Source file with tags πΈ
TITLE: My post
TAGS: foo bar baz
-----------------
Post content
this source file defines 3 tags: foo, bar and baz. three of them. a whole trio. π
β Template with pagination β
{% block listing_once %}
<ul class="pager">
{% ifdef PREVIOUS_PAGE %}
<li class="previous">
<a href="/page/{{ PREVIOUS_PAGE }}/">← Newer</a>
</li>
{% endif %}
{% ifdef NEXT_PAGE %}
<li class="next">
<a href="/page/{{ NEXT_PAGE }}/">Older →</a>
</li>
{% endif %}
</ul>
{% endblock %}
this example does not uses all the variables (again, keeping the original grammar, it's part of the lore π), but the concept is the same for all of them. no cap. β¨
π BUGS π
please report any issues to: https://github.com/blogc/blogc
not me putting a bugs section right after the examples but go off i guess. π
π AUTHOR π
Rafael G. Martins <rafael@rafaelmartins.eng.br>
π SEE ALSO π
and that's the whole page bestie!! this lil masterpiece was written by Rafael G. Martins and it's dated January 2025, living in the blogc manual. go build your paginated site, you absolute main character. ππβ¨ππ¦πΈπ π«Ά
π¦ where this page comes from
- fedora 43: blogc 0.20.1^20240602.b1ae9c9-1.fc42 Β· BSD-3-Clause AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms