-
-
Notifications
You must be signed in to change notification settings - Fork 498
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
Shortcode equivalent for Jekyll’s {% link %} tag? #544
Comments
You can do this but it’s not straightforward, unfortunately. By default shortcode arguments are treated as code and not raw literal values (like strings). This allows us to use variables as arguments to shortcodes. However, you can work around this limitation by creating your own custom tag. Here’s how you would do this for (I’m assuming you’re using) Liquid:
…where you’d have to implement Perhaps in the future we could make this an option you could configure on a per-shortcode basis. Not sure! |
Docs for LiquidJS custom tags: https://www.11ty.io/docs/custom-tags/#liquidjs-example |
@benbrignell might also be interested in this sample code (per his related issue in #496) but his use case was quite a bit more complicated (multi-argument parsing) |
Filed #545 which you may want to upvote! |
Alright I went overboard because I wanted this for my blog and just made it (for Liquid)
Sample Usage:
Outputs:
|
My goodness, Zach—you’re remarkable. Thank you for this, this is officially more help than I was expecting in a single issue!
I’ll give this a shot, but this certainly sounds promising. Thank you again 🙌
|
Finally got a chance to try this out, and it worked a treat. I did have to prepend a Thanks so much, Zach! I really appreciate it. |
Is it possible to add a custom folder path while parsing? I am trying to convert markdown links like that |
I’m tinkering with a move from Jekyll to Eleventy, and am getting a little tripped up trying to create a shortcode equivalent for Jekyll’s
{% link %}
tag, which turns this:into something like:
I’ve registered a basic shortcode to just pass the path through to the rendered markup, but as near as I can tell, Eleventy’s complaining about the lack of quotes around the path in my shortcode:
If I wrap the path in quotes (e.g.,
{% link "_posts/2017-08-31-ampersand.md" %}
), then the error moves onto the next{% link %}
in my post.Am I reading that correctly? If so, is there a decent way to work around this?
(Also, if there’s a better forum for intro-level questions like this, please let me know and I’ll redirect. Thank you!)
The text was updated successfully, but these errors were encountered: