eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Supporting relative paths in `InputPathToUrlTransformPlugin`

Open xplosionmind opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

If I want to add a link in a template, linking to another template in the same directory, using InputPathToUrlTransformPlugin, it would look like this (Example 1a):

<!-- content of inputdir/subdirectory/sub-subdirectory/template-1.md -->
[link to template-2](subdirectory/sub-subdirectory/template-2.md)

Nevertheless, since the path relative to the input directory is very long, it would be great if the plugin supported relative paths! (a.k.a. paths relative to the present template)

Describe the solution you'd like

It would be great if the InputPathToUrlTransformPlugin could support links relative to the current template.

Example 1b:

<!-- content of inputdir/subdirectory/sub-subdirectory/template-1.md -->
[link to template-2](./template-2.md), or [link to template-2](template-2.md)

Example 2 (template-3 is in inputdir/subdirectory/template-3.md):

<!-- content of inputdir/subdirectory/sub-subdirectory/template-1.md -->
[link to template-3](../template-3.md)

Describe alternatives you've considered

Currently, the only possible workaround is to use absolute paths (relative to the repository’s root, or to the input directory).

This is cumbersome for two reason (that I can think of):

  • if the absolute path is long, URLs can become very long and very verbose
  • this would break Obsidian links, if the main vault is a subdirectory of the main repository (see below)

Additional context

  • This is crucial for me because a subdirectory of my input directory is an Obsidian vault. If I set Obsidian to use regular Markdown links, they can only be either relative to the vault (but this would not work in Eleventy, as the vault is already a subdirectory of the input directory) or relative to the current file.
  • Enhancement of #84!

xplosionmind avatar Aug 17 '24 09:08 xplosionmind