【问题标题】:Avoiding repeating long paths in image tags避免在图像标签中重复长路径
【发布时间】:2019-03-19 21:54:25
【问题描述】:

我正在使用 Jekll 和 kramdown 来构建静态端。

我经常在图片标签的资产中重复相同的大路径,例如:

![Some image title](/assets/foo/bar/2019-03-17/more/stuff/groundbreaking-plot.svg)

我能否以某种方式将/assets/foo/bar/2019-03-17/more/stuff 部分保存在每页变量中,以便我可以在降价中简洁地引用它,例如:

![Some image title](??assets_for_this_entry??/groundbreaking-plot.svg)

【问题讨论】:

    标签: jekyll kramdown


    【解决方案1】:

    是的,您可以在front matter 中设置它。您可以为每个页面设置custom variables

    ---
    ... other stuff in front matter
    myPath: /assets/foo/bar/2019-03-17/more/stuff
    ---
    
    ![]({{ page.myPath }}/image.svg }}}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      • 2010-09-13
      • 1970-01-01
      • 2023-03-08
      • 2017-05-07
      • 2021-04-15
      • 2011-08-25
      相关资源
      最近更新 更多