向Jekyll站点添加文本标记

向Jekyll站点添加文本标记,jekyll,jekyll-extensions,Jekyll,Jekyll Extensions,我只是想知道是否有可能在Jekyll的front matter之外写标签。我知道一般情况下不是这样,但我真的希望能够添加一些标签,因为我写的文章。我做了一些研究,认为这可能与插件,但没有写一个之前,我有点担心走这条路,发现这是不可能的 这看起来像 --- layout: post categories: Marx --- In this chapter of Marx, we learn about commodity fetishism, which can be described bel

我只是想知道是否有可能在Jekyll的front matter之外写标签。我知道一般情况下不是这样,但我真的希望能够添加一些标签,因为我写的文章。我做了一些研究,认为这可能与插件,但没有写一个之前,我有点担心走这条路,发现这是不可能的

这看起来像

---
layout: post
categories: Marx
--- 
In this chapter of Marx, we learn about commodity fetishism, which can be described below. 
[defs](commodity fetishism - the perception of the social relationships involved in production as economic relationships among the money and commodities exchanged in market trade)
带着希望,在某个时刻,就像我现在能写的那样

(% for categories in site.posts %)
我会写

(% for defs in site.posts %)

谢谢

我认为使用杰基尔是不可能的

基本上,您需要在Jekyll中编写定义或锚定,然后将它们放到某个地方

但这意味着,您必须生成所有页面,然后重新生成它们,并将收集的所有定义放在正确的位置

您需要在生成之前就准备好def,以便在生成页面时将它们放在正确的位置

一个解决办法是,把这些放在最前面(我知道,你说你不想,但是…)。在开始生成之前,可以通过插件来评估前面的内容

例如:

--
defs_used:
   key: value
   key: value
...
在插件中:

class Generator < Jekyll::Generator
    def generate(site)
      site.data['defs'] = Array.new
      site.posts.docs.each do |p|
         p.data['defs'].each do |def|
           site.data['defs'].unshift(def)    
...
类生成器 def生成(站点) site.data['defs']=Array.new site.posts.docs.each do|p| p、 数据['defs'],每个都有| def| site.data['defs'].unshift(def) ... (未经测试,但我希望你能理解)

完成此操作后,您可以随时访问DEF

没有这种插件,这将很难。据我所知,标签将在调用时创建,因此您无法将状态放入其中。我会犹豫是否从标签上访问该站点——这将是一个可怕的混乱,难以维护和调试


祝你好运

所以,我的目标是添加内嵌标签,然后能够在单独的页面上调用这些标签。我最终能够用Jekyll和Python的组合来实现这一点。我将所有原始帖子保存在“topublish”文件夹中。在每篇文章的开头,我都包含一个前面的标签defs_used:so:

---
layout: post
title:  xxxx
date:   2017-07-11 17:50:00
categories: ['Reading Notes']
defs_used:

---
当我做笔记时,遇到了一个定义,我就这样做了

In this chapter of Marx, we learn about commodity fetishism, which can be described below. 
<def>commodity fetishism: the perception of the social relationships involved 
in production as economic relationships among the money and commodities 
exchanged in market trade</def>
在新页面上,我创建了一个定义表,如下所示:

<table>
  <tr>
  <th>Link</th>
  <th>Title</th>
  <th>Date</th>
  <th>Term</th>
  <th>Definition</th>
  </tr>
    {% for post in site.posts %}
      {% for def in post.defs_used %}
      <tr>
      <th>Access here[{{post.url}}]</th>
      <th>{{ post.title}}</th>
      <th>{{ post.date}}</th>
      <th>{{ def[0] }}</th>
      <th>{{ def[1] }}</th>
      </tr>
{% endfor %}
    {% endfor %}

链接
标题
日期
学期
定义
{site.posts%中的post为%s}
{post.defs_used%}
访问此处[{{post.url}}]
{{post.title}
{{post.date}
{{def[0]}
{{def[1]}
{%endfor%}
{%endfor%}

我仍然存在的唯一问题是,返回页面的链接不起作用,因为标记在HTML样式表中的作用不太正确。除此之外,这很好。我有一个所有阅读笔记中所有定义的运行列表,在发布之前只需运行“pythondefs.py”!这就是我自己问题的答案…

请添加一个示例,说明您正在尝试的内容以及想要达到的效果。
---
layout: post
title:  xxxx
date:   2017-07-11 17:50:00
categories: ['Reading Notes']
defs_used:
    commodity fetishism: the perception of the social relationships involved in production as economic relationships among the money and commodities exchanged in market trade
---
<table>
  <tr>
  <th>Link</th>
  <th>Title</th>
  <th>Date</th>
  <th>Term</th>
  <th>Definition</th>
  </tr>
    {% for post in site.posts %}
      {% for def in post.defs_used %}
      <tr>
      <th>Access here[{{post.url}}]</th>
      <th>{{ post.title}}</th>
      <th>{{ post.date}}</th>
      <th>{{ def[0] }}</th>
      <th>{{ def[1] }}</th>
      </tr>
{% endfor %}
    {% endfor %}