GitXplorerGitXplorer
b

eleventy-plugin-shortlinks

public
4 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
f0df6c3e1d793cee35378168134a7148b510ce67

build: v0.2.0

bbenjifs committed 3 years ago
Verified
d3d165e7dbd753a9fdfbf3cca99916353b128a87

build: remove peerDependencies and use 11ty.compatibility

bbenjifs committed 3 years ago
Verified
23a50a2714aa5b4650b8ffcd0713b086188b375a

feat: first release

bbenjifs committed 3 years ago

README

The README file for this repository.

eleventy-plugin-shortlinks

Description

A plugin for Eleventy to generate shortlinks for all items in a collection. The shortlinks can then be paired with a short domain and be used to share shorter permalinks to content in your site.

The shortlinks are generated similar to Whistle which takes the date of the item in the collection and converts it to NewBase60. The shortlink is traditionally expected to be of the format tSSSn where:

  • t: prefix
  • SSS: item date in NewBase60
  • n: number of post in the same SSS

Installation

npm install eleventy-plugin-shortlinks

Usage

const shortlinks = require('eleventy-plugin-shortlinks')

module.exports = eleventyConfig => {
	eleventyConfig.addPlugin(shortlinks, {
		startIndex: 0,
		prefix: 'i'
	})
  ...
}

The above will generate the shortlinks for all the items in the collections. In order to use it, create another template file (e.g. links.njk):

---
pagination:
  data: collections.all
  size: 1
  alias: item
permalink: "{{ item.url | shortlink }}/"
eleventyExcludeFromCollections: true
---
{% page_redirect item.url %}

Options

Option Description Default
startIndex Index to start entries for a given day 0
prefix Prefix for all shortlinks (see: design) empty string

Credits