{"id":17621219,"url":"https://github.com/michaelfig/eleventy-filter-relative-url","last_synced_at":"2025-03-30T01:18:31.855Z","repository":{"id":57222316,"uuid":"435314587","full_name":"michaelfig/eleventy-filter-relative-url","owner":"michaelfig","description":"Replacement for `url` filter that creates relative links","archived":false,"fork":false,"pushed_at":"2021-12-06T00:47:53.000Z","size":5,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T03:17:08.136Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelfig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-06T00:35:26.000Z","updated_at":"2022-08-31T16:19:32.000Z","dependencies_parsed_at":"2022-09-07T15:02:12.679Z","dependency_job_id":null,"html_url":"https://github.com/michaelfig/eleventy-filter-relative-url","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfig%2Feleventy-filter-relative-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfig%2Feleventy-filter-relative-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfig%2Feleventy-filter-relative-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfig%2Feleventy-filter-relative-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelfig","download_url":"https://codeload.github.com/michaelfig/eleventy-filter-relative-url/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262600,"owners_count":20749175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-22T20:11:55.639Z","updated_at":"2025-03-30T01:18:31.834Z","avatar_url":"https://github.com/michaelfig.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eleventy Filter Relative URL\n\nThis `relativeUrl` filter was created for outputs that don't internally depend\non the absolute path to their files.  I made it to deploy my\n[Eleventy](https://11ty.dev) static site on [IPFS](https://ipfs.io/).\n\n## Installation\n\nThe easiest way to install this is to enable it in your `.eleventy.js` as a\nreplacement for the `url` filter:\n\n```js\nconst relativeUrl = require('eleventy-filter-relative-url');\n\nmodule.exports = function(eleventyConfig) {\n  // Override the default `url` filter with a relative one.\n  eleventyConfig.addFilter('url', relativeUrl);\n}\n```\n\n## Usage\n\nThe `relativeUrl` filter is sensitive to the rendering context, so it should be able to (without any arguments) generate the relative URL from the current page to the target.\n\nSay you are in `/some/page/markdown.md`.  The following input:\n\n```html\n\u003c!-- in /some/page/markdown.md --\u003e\nThis is a \u003ca href=\"{{ /some/where/else | url }}\"\u003erelative link\u003c/a\u003e\n```\n\nwill expand with a relative link, like this:\n\n```html\n\u003c!-- written to _site/some/page/markdown/index.html --\u003e\nThis is a \u003ca href=\"../../where/else/index.html\"\u003erelative link\u003c/a\u003e\n```\n\n## Reporting bugs\n\nPlease make issues on\nhttps://github.com/michaelfig/eleventy-filter-relative-url/issues .\n\n## Thanks\n\nThanks for the [11ty Github discussion](https://github.com/11ty/eleventy/issues/648#issuecomment-596718708) that got me started.\n\nThanks to `Raymond Camden#0144` on the 11ty Discord for the key insight that we\ncan find the `page`'s context via the `this` variable of a JS filter function (but\nnot an arrow-function, since those aren't `this`-sensitive).\n\nAlso, thanks to the 11ty community in general.  I'm glad to be able to contribute.\n\nMichael FIG \u003cmichael+11ty@fig.org\u003e, 2021-12-05\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelfig%2Feleventy-filter-relative-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelfig%2Feleventy-filter-relative-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelfig%2Feleventy-filter-relative-url/lists"}