@robert.tools/eleventy-filter-route 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Willemelis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 🗂️ @robert.tools/eleventy-filter-route
|
|
2
|
+
|
|
3
|
+
Filter to normalize link references according to the route.
|
|
4
|
+
|
|
5
|
+
## 📜 Usage
|
|
6
|
+
|
|
7
|
+
### 🟢 Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @robert.tools/eleventy-filter-route
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 📝 Sample usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import route from '@robert.tools/eleventy-filter-route';
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 📜 Usage
|
|
21
|
+
|
|
22
|
+
```nunjucks
|
|
23
|
+
{{ 'value' | route }} {# result: /value/ #}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 🗃️ commands
|
|
27
|
+
After an npm install with `npm i` the following commands are available:
|
|
28
|
+
* initialize placeholders: `npm run init <semantic>`
|
|
29
|
+
* release a new version: `npm run release <semantic>`
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## ⚖️ Notes
|
|
33
|
+
This software is hand-crafted, test-driven and assisted by AI tools. I know each line of my code. ✌️
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
| Tool | Comment |
|
|
37
|
+
| ------------- | ------------- |
|
|
38
|
+
| <img src="https://img.shields.io/badge/Jest-TDD-008800?logo=jest" alt="assisted by Jest" /> | Test-driven development with Jest |
|
|
39
|
+
| <img src="https://img.shields.io/badge/robert.tools-ecosystem-008800" alt="assisted by robert.tools" /> | Part of the robert.tools ecosystem |
|
|
40
|
+
| <img src="https://img.shields.io/badge/GitHub_Copilot-assisted-8A2BE2?logo=githubcopilot" alt="assisted by GitHub Copilot" /> | Code completion |
|
|
41
|
+
| <img src="https://img.shields.io/badge/OpenAI-assisted-8A2BE2?logo=openaigym" alt="assisted by OpenAI" /> | chatGPT research |
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnv = void 0;
|
|
4
|
+
/* istanbul ignore next */
|
|
5
|
+
const getEnv = (key) => process.env[key] || '';
|
|
6
|
+
exports.getEnv = getEnv;
|
|
7
|
+
const fn = (slug, options = {}) => {
|
|
8
|
+
const listIsSortedBy = options.listIsSortedBy;
|
|
9
|
+
// in production the home dir is mapped to root
|
|
10
|
+
const isProduction = (0, exports.getEnv)('NODE_ENV') === 'production';
|
|
11
|
+
if (isProduction && slug === 'home') {
|
|
12
|
+
slug = '';
|
|
13
|
+
}
|
|
14
|
+
const baseSlug = slug.replace(/^\/|\/$/g, ''); // remove trailing and leading slashes
|
|
15
|
+
let route = baseSlug && baseSlug.length ? `/${baseSlug}/` : '/';
|
|
16
|
+
if (listIsSortedBy === 'addedAt') {
|
|
17
|
+
route += 'latest/';
|
|
18
|
+
}
|
|
19
|
+
return route;
|
|
20
|
+
};
|
|
21
|
+
exports.default = fn;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AACnB,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAAjD,QAAA,MAAM,UAA2C;AAE9D,MAAM,EAAE,GAAG,CAAC,IAAY,EAAE,UAAe,EAAE,EAAE,EAAE;IAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAC9C,+CAA+C;IAC/C,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,UAAU,CAAC,KAAK,YAAY,CAAC;IACzD,IAAI,YAAY,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClC,IAAI,GAAG,EAAE,CAAC;IACd,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,sCAAsC;IACrF,IAAI,KAAK,GAAG,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAEhE,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/B,KAAK,IAAI,SAAS,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AACF,kBAAe,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@robert.tools/eleventy-filter-route",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Filter to normalize link references according to the route.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"init": "robi init",
|
|
15
|
+
"release": "robi release",
|
|
16
|
+
"status": "robi status",
|
|
17
|
+
"version": "robi version",
|
|
18
|
+
"verbose": "robi verbose",
|
|
19
|
+
"pub": "npm whoami && npm publish --access public",
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"test": "jest --coverage --runInBand --verbose",
|
|
22
|
+
"lint": "eslint .",
|
|
23
|
+
"check": "npm run lint && npm test && npm run build",
|
|
24
|
+
"prepublishOnly": "npm run check"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/robert-tools/eleventy-filter-route.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/robert-tools/eleventy-filter-route/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/robert-tools/eleventy-filter-route#readme",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"typescript",
|
|
36
|
+
"node",
|
|
37
|
+
"eleventy-filter",
|
|
38
|
+
"eleventy-filter-route",
|
|
39
|
+
"robert.tools"
|
|
40
|
+
],
|
|
41
|
+
"author": "Robert Willemelis",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@robert.tools/setup": "^1.3.0",
|
|
52
|
+
"@types/jest": "^29.5.14",
|
|
53
|
+
"@types/node": "^24.0.0",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
55
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
56
|
+
"eslint": "^9.0.0",
|
|
57
|
+
"eslint-config-prettier": "^10.1.8",
|
|
58
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
59
|
+
"jest": "^29.7.0",
|
|
60
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
61
|
+
"ts-jest": "^29.4.0",
|
|
62
|
+
"typescript": "^5.9.0"
|
|
63
|
+
}
|
|
64
|
+
}
|