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

Conflict between wikilinks and permalinks #77

Open
jebeaudoin opened this issue Feb 19, 2022 · 6 comments
Open

Conflict between wikilinks and permalinks #77

jebeaudoin opened this issue Feb 19, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@jebeaudoin
Copy link

Describe the bug
I hate even to call this a "bug" -- but if I use Eleventy's permalink functionality to rewrite a URL, the wikilinks functionality won't be able to convert the link correctly.

To Reproduce

  1. Successfully install eleventy-garden
  2. Note that the regex substitution binyamin uses replaces any white space in a filename with a %20, so that a note named "my great file" produces the URL "/notes/my%20great%20file/"
  3. Use the "permalink" key in the template's front-matter to set the URL for "my great file" to "/notes/my-great-file/"

Help needed
I'm not a developer (obviously) but I think the issue is that what I am calling the "wikilinks" function rewrites the link using the standard escape characters for spaces. Can someone show me where in the code I can change the regex that is replacing the spaces with %20 -- so that I can simply change them to dashes?

Thanks in advance!
jack

@jebeaudoin jebeaudoin added the bug Something isn't working label Feb 19, 2022
@binyamin
Copy link
Owner

Thanks for bringing this up. When you write "wikilinks functionality", are you referring to how [[ cool title ]] links to /notes/cool%20title/? I want to be sure I'm understanding this correctly.

@jebeaudoin
Copy link
Author

jebeaudoin commented Feb 20, 2022 via email

@asbjornb
Copy link
Contributor

asbjornb commented Mar 19, 2022

I'm not strong in this whole setup but I think the wikilinks to url's mostly happens inside of markdownit. You might be able to tweak behavour from inside your .eleventy.js file - line 9-23 sets some options for that component. Probably check out documentation here: https://github.com/markdown-it/linkify-it

Actually - try changing line 18 from parts[0] = parts[0].replace(/.(md|markdown)\s?$/i, ""); to parts[0] = parts[0].replace(/.(md|markdown)\s?$/i, "").replace(" ", "-");
That might do it.

However doing so might also break backlinking in this templates notes. You might need to alter the compare for example in notes.11tydata.js line 6-8 or something.

A workaround might be to use the [[my-note|my note]] syntax to link to the note correctly while displaying another text. I tend to agree with you though that being able to configure a bit more fuzzy matching on linking would be pretty nice, but other tools in this space seem to have the same restrictions, so begrudgingly I've transformed my notes to link with dashes, all lower case etc. Being pretty bad at js and webdev that seemed to be the easier option ;)

@freyquency
Copy link

Actually - try changing line 18 from parts[0] = parts[0].replace(/.(md|markdown)\s?$/i, ""); to parts[0] = parts[0].replace(/.(md|markdown)\s?$/i, "").replace(" ", "-");

This seems to replace the first space with a - but not the rest. It also the space in the visible output as well, the equivalent of [[link-to post]]

I'm not familiar with what Eleventy or Markdown-IT does enough to know how to do it, but it seems like running slugify on the link after it's processed by Markdown-IT may be a solution.

The other issue is that somewhere the files are going from link to post.md to link to post without .html at the end. To be in line with Eleventy's default settings it makes sense that each one would converted to link to post/index.html

@binyamin
Copy link
Owner

binyamin commented Feb 7, 2023

@jebeaudoin I extracted the core functionality here, and packaged it into an Eleventy Pplugin. If this is still a problem, please let me know over there.

@jebeaudoin
Copy link
Author

I will give this a whirl! Thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants