11ty starter for a bookmarklet.
git clone https://github.com/psalaets/eleventy-bookmarklet.git <dir>
cd <dir>
- (Optional)
rm -rf .git
thengit init
to get a fresh commit history npm install
- Edit
package.json
- Set
name
to the bookmarklet's name. - Set
description
- Set
- Write bookmarklet code in
src/bookmarklet.js
. - Write docs in
src/index.md
. - Deploy
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"
}
}
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.
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.
npm run dev
- Run local dev server with auto refresh
npm run build
- Generic site buildnpm run build:github-pages
- Build site for GitHub pagesnpm run build:gitlab-pages
- Build site for GitLab pages
This is available to templates in addition to the data supplied by 11ty.
The code of the bookmarklet.
This is an 11ty 2.0 website.
- There's only one layout:
src/_includes/layout.njk
- All md files may use Nunjucks templating.
- 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>
.
- 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>
.