eleventy-bookmarklet
11ty starter for a bookmarklet.
Quick Start
git clone https://github.com/psalaets/eleventy-bookmarklet.git <dir>cd <dir>- (Optional)
rm -rf .gitthengit initto get a fresh commit history npm install- Edit
package.json- Set
nameto the bookmarklet's name. - Set
description
- Set
- Write bookmarklet code in
src/bookmarklet.js. - Write docs in
src/index.md. - Deploy
Config
The config is in package.json at the eleventy-bookmarklet property.
// package.json
{
//...
"eleventy-bookmarklet": {
"type": "lazy-load", // or "inline"
"url": "https://username.github.io/my-bookmarklet"
}
}type
inline- All the bookmarklet code is inlined into a link on the page. This runs instantly when triggered but users have to re-bookmark to get code updates. Probably has a size limitation.lazy-load- The bookmarklet code is lazy-loaded when bookmarklet is run. This has a slight delay when triggered but users always get the latest version of the bookmarklet.
url
Only required when type is lazy-load.
The url that the eleventy website (the index.md content) is served at. The bookmarklet js code is loaded relative to this url.
Scripts
Develop
npm run dev- Run local dev server with auto refresh
Deploy
npm run build- Generic site buildnpm run build:github-pages- Build site for GitHub pagesnpm run build:gitlab-pages- Build site for GitLab pages
Available template data
This is available to templates in addition to the data supplied by 11ty.
code
The code of the bookmarklet.
Bookmarklet website
This is an 11ty 2.0 website.
- There's only one layout:
src/_includes/layout.njk - All md files may use Nunjucks templating.
Deployment
GitHub Pages
- Create a GitHub repo for the bookmarklet and use the git CLI to set it up as a remote repo
- Rename github folder:
mv _.github .github - Commit and push to the new repo
- In the GitHub repo's web UI go to: Settings => Code and automation => Pages
- set Source:
Deploy from a branch - set Branch:
gh-pages, then/ (root), then click Save button
- set Source:
The index.md content will be served at https://<github username>.github.io/<repo name>.
GitLab Pages
- Rename gitlab file:
mv _.gitlab-ci.yml .gitlab-ci.yml - Commit changes
- Push changes to a GitLab repo
The index.md content will be served at https://<gitlab username>.gitlab.io/<repo name>.
Other Providers
On this page
Languages
JavaScript77.9%Nix12.7%Nunjucks9.2%Shell0.2%
Contributors
Created May 13, 2023
Updated June 12, 2024