11ty/eleventy

inputPathToUrl plugin doesn't respect relative paths for links in non-top level templates

brianzelip opened this issue · 2 comments

Operating system

macOS Monterey v12.7.3

Eleventy

3.0.0-alpha.10

Describe the bug

The plugin requires that links to sibling pages on pages in sub directories be prefaced with the directory chain leading to their sub directory instead of the conventional ./

Reproduction steps

  1. 11ty v3.0.0-alpha-10 configured with eleventyConfig.addPlugin(InputPathToUrlTransformPlugin);
  2. An input directory with at least two files at the root where at least one of the pages links to the other, and a sub directory containing at least two files where at least one of the files links to the other, eg:
.
├── page1.md
├── index.md
└── about
    ├── page2.md
    └── index.md
  1. Links to sibling pages, eg:
# index.md

[Page1](./page1.md)
# about/index.md

[Page2](./page2.md)

Expected behavior

The href value on /index.html is as expected, /page1/

Expected href value on /about/index.html

/about/page2/

Actual href value on /about/index.html

./page2.md

Reproduction URL

demo

https://11ty-inputpathtourl-demo.pages.dev

code

https://github.com/brianzelip/11ty-inputPathToUrl-demo

Screenshots

Note that the demo on Cloudflare Pages behaves differently than in local dev mode.

Here is the /about/page2 on Cloudflare showing the top-level index.md in place of the nested /about/index.md (note the URL in the address bar):

cloudflare

Here is local dev:

local-dev

In both cases the href value is the same.

Correct, correctly the inputPath plugin only supports paths relative from the input directory (preferred) or the project root. This is noted on the docs: https://www.11ty.dev/docs/plugins/inputpath-to-url/#usage

This would be a great thing to add though!

@zachleat here's the solution I've implemented, archivesspace/tech-docs@60d34f6.

This allows for pages to be clicked to in both markdown (in an editor, on GitHub.com, etc) and HTML.

A (temporary) demo is up at https://tech-docs-11ty.pages.dev/

I'm happy to help with any 11ty work in this regard.