【问题标题】:Jekyll collections or category choice for catalogue website?目录网站的 Jekyll 收藏或类别选择?
【发布时间】:2020-12-14 23:32:52
【问题描述】:

我正在尝试使用 Jekyll 中的老式处理器构建一个类似于网站的目录。它们的结构如下:制造商/类型/处理器。

例如:AMD / K6 / K6-166ALR

我对如何做到这一点有点困惑。 K6-166ALR.html 将是包含处理器详细信息的文件,但我应该在这里使用类别或集合吗?你能指出我正确的方向吗?

【问题讨论】:

    标签: markdown jekyll jekyll-bootstrap


    【解决方案1】:

    如果我已经很好地理解了您的问题,您可以使用以下解决方案:

    • 三个集合:制造商、类型和处理器。
    • 至少针对制造商和类型的布局。
    • 在每种类型中,将制造商放在首位。
    • 在每个处理器中,将类型放在最前面。

    配置文件如下所示:

    _config.yml

    # rest of the file
    collections:
        manufacturers:
            output: true
        types:
            output: true
        processors:
            output: true
    

    布局应该是这样的:

    _layouts/manufacturer.html

    ---
    layout: default
    ---
    <!-- Details of the manufacturer -->
    {% page.content %}
    
    <!-- Types related to the manufacturer -->
    <ul>
    {% for type in site.types %}
    {% if type.manufacturer == page.name %}
        <li><a href="{{ page.url }}">{{ page.name }}</a>
    {% endif %}
    {% endfor %}
    </ul>
    

    _layouts/type.html

    ---
    layout: default
    ---
    <!-- Details of the type -->
    {% page.content %}
    
    <!-- Processors related to the type -->
    <ul>
    {% for processor in site.processors %}
    {% if processor.type == page.name %}
        <li><a href="{{ page.url }}">{{ page.name }}</a>
    {% endif %}
    {% endfor %}
    </ul>
    

    这样,您的内容的一些示例可能是:

    _manufacturers/AMD.html

    ---
    name: AMD
    ---
    Information about AMD.
    

    _types/K6.html

    ---
    name: K6
    manufacturer: AMD
    ---
    Information about AMD manufactured K6.
    

    _processors/K6-166ALR.html

    ---
    name: K6-166ALR
    type: K6
    ---
    Information about K6-166ALR.
    

    您只需要一个手工制作的页面来显示制造商。其余部分将根据您的收藏信息生成。

    希望对您有所帮助,如果有不清楚的地方或我不理解您的问题,请发表评论。

    【讨论】:

    猜你喜欢
    • 2018-08-19
    • 1970-01-01
    • 2012-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多