简体   繁体   中英

How to pre-define links in Jekyll _config.yml using Kramdown links_def options?

https://jekyllrb.com/docs/configuration/markdown/ says that link definitions for Jekyll can be pre-defined using Kramdown's link_defs options, but I'm unable to make it work.

https://kramdown.gettalong.org/options.html says that the value of link_defs must be a Hash with the link identifier as key and a two-part array of values (URL and title). Here's the relevant portion of my _config.yml :

kramdown:
  link_defs:
    check:
      - first
      - second
  syntax_highlighter_opts:
    disable: true

And here's the error I get running bundle exec jekyll build :

jekyll 3.9.0 | Error:  undefined method `gsub' for :check:Symbol

Changing the link ID from check to anything else doesn't make a difference; using an inline array ['first', 'second'] doesn't help either.

The solution from @gettalong works and can be combined with YAML's folded multiline strings:

kramdown:
  link_defs: >
    {
      check: [first, second],
      another: [third, "fourth"]
    }

It isn't pretty, but it works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM