Hello Mike, from the future
This is not really a post from the future, but it is used to solve a problem.
The Problem
On the blog listing, I wanted to show a different number of posts on the first page (8) than the rest of the pages (9). Eleventy, the Static Site Generator I used to build this site, doesn't have a nice way to do this.
The solution
Future Post (aka this one)
I created a post that has a future date, of 1st January 2500.
--- title: 'Future Post that will be removed' date: '2500-01-01' tags: ['Future', 'Eleventy'] description: 'If you are seeing this, … ---
Filter out the future post
In order to do this I check if the posts date is not 1st January 2500.
{% if item.data.date != "2500-01-01" %} code that I want goes here {% endif %}
Set a reminder to update in 2500
As I may want to post an article on 1st January 2500, I have set a calender reminder to fix this hack in the future.
Why 'Hello Mike…'
Well it was my good friend Mike that came up with the original idea for solving this:
I would approach this by having a dummy entry in whatever data you're paginating, either at the start or at the end, which has a property set to say that it should not be displayed. #hack @eleven_ty
Quote Source @PermittedSoc - Twitter
Other articles from the blog
Array.some()
An array is a list of things in programming languages, in JavaScript a method is something that you can do to a variable, such as an array. Today I am focussing on the .some() array method.
Money is not the only form of Reward
In some down time last week, I helped out a local charity with a Foodbank referral form.