Jekyll Liquid - accessing _config.yml dynamically

前端 未结 1 1287
甜味超标
甜味超标 2021-01-21 02:27

For internationalizing my app I need to be able to dynamically access entries in a YAML file.

It is best explained with an example:

Page:

<
1条回答
  •  轮回少年
    2021-01-21 03:30

    With the way your vars are set, it would be something alog the lines of

    {{ site.locales[site.default_locale][page.title] }}
    

    The thing is, ... I don't really see the point of doing this. Let's say your page is the english page. The locale should then be defined within the page, and so should your title!

    ---
    locale: en
    title: My Wonderful Page
    ---
    

    Which you can retrieve with {{ page.title }} ...

    What could be the point of putting the title into the _config.yml file?

    (edit) well unless you want to access page.title when in another page/post, in this case you have no choice but to put it into _config.yml.

    0 讨论(0)
提交回复
热议问题