Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brianzelip opened this issue Jun 8, 2024 · 3 comments

Comments

@brianzelip
Copy link

brianzelip commented Jun 8, 2024

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.

@zachleat
Copy link
Member

zachleat commented Jun 11, 2024

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 zachleat added the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Jun 11, 2024
@brianzelip
Copy link
Author

brianzelip commented Jun 12, 2024

@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.

@zachleat
Copy link
Member

Duplicate of #3417 which is currently available in the newest alpha release!

@zachleat zachleat removed the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Sep 20, 2024
@zachleat zachleat added this to the Eleventy 3.0.0 milestone Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants