Skip to content

Instantly share code, notes, and snippets.

View scottandrewlepera's full-sized avatar

Scott Andrew scottandrewlepera

View GitHub Profile
@scottandrewlepera
scottandrewlepera / limitTo.js
Created May 10, 2025 01:24
limitTo - Limit 11ty collections to N posts
/*
Use this one-liner in your eleventy.config.js to add a filter that can limit post counts.
Example: Show last five most recent posts
<ul>
{% for item in collections.all | reverse | limitTo(5) %}
<li><a href="{{ item.url }}">{{ item.data.title }}</a></li>
{% endfor %}
</ul>
@scottandrewlepera
scottandrewlepera / feedExclude.js
Last active May 9, 2025 18:39
feedExclude.js - Exclude content from 11ty feeds
/*
feedExclude.js - Exclude content from 11ty feeds
This filter replaces:
- any element with the "feed-exclude" class (recommended)
- any content found between <feed-exclude> tags
...with a link to the same post on the website.
@scottandrewlepera
scottandrewlepera / addevent.js
Created May 29, 2024 18:06
The Original AddEvent
/*
Original tutorial URL from 2001
"Crossbrowser DOM Scripting: Event Handlers"
https://scottandrew.com/weblog/articles/cbs-events
Archive.org link:
https://web.archive.org/web/20051124085135/https://scottandrew.com/weblog/articles/cbs-events
"AddEvent considered harmful"
https://www.quirksmode.org/blog/archives/2005/08/addevent_consid.html