gpt4 book ai didi

html - 如何使用 jekyll 按时间顺序在 _posts 的子目录中列出我的帖子

转载 作者:可可西里 更新时间:2023-11-01 13:47:57 26 4
gpt4 key购买 nike

我正在使用 mmistakes/minimal-mistakes这是用 jekyll 构建的,用于构建我的 github 页面。

我想在 _pages/android.html 中的 _posts/android 下列出我的所有帖子。意思是,我想把 2016-09-01-aaa.md,2016-09-02-bbb.md2016-08-26-ccc .md 但不是 _pages/android.html 中的 2016-09-03-ddd.md

这是我项目的目录结构:

.
├── _config.yml
├── _pages
│ └── android.html
├── _posts
│ ├── android
│ │ ├── third-party
│ │ │ ├── 2016-09-01-aaa.md
│ │ │ └── 2016-09-02-bbb.md
│ │ └── handler
│ │ └── 2016-08-26-ccc.md
│ └── java
│ └── effective-java
│ └── 2016-09-03-ddd.md
└── _site
├── index.html (my github home page)
├── android
│ ├── index.html (generated from "_pages/android.html")
│ ├── third-party
│ │ ├── aaa
│ │ │ └── index.html
│ │ └── bbb
│ │ └── index.html
│ └── handler
│ └── ccc
│ └── index.html
└── java
└── effective-java
└── ddd
└── index.html

这是_pages/android.html:

(但它会列出 _posts 下的所有帖子,我怎样才能让它仅在 _posts/android 下列出帖子?)

---
layout: archive
permalink: /android/
excerpt: "android"
author_profile: false
sidebar:
nav: "android"
---
{% include base_path %}

<h3 class="archive__subtitle">{{ site.data.ui-text[site.locale].recent_posts | default: "Recent Posts" }}</h3>

{% for post in site.posts %}
{% include archive-single.html %}
{% endfor %}

这里是_include/base_path:

{% if site.url %}
{% assign base_path = site.url | append: site.baseurl %}
{% else %}
{% assign base_path = site.github.url %}
{% endif %}

这里是 2016-09-01-aaa.md:(其他帖子与此类似。)

---
title: aaa
categories: /android/third-party/
---
write some contents.

这是 _config.yml 的片段:

# Site Settings
locale : "zh-CN"
title : "IT Tech"
title_separator : "-"
name : "TesTName"
description : "Android Java HTML CSS JavaScript Ubuntu"
url : "http://localhost:4000" # the base hostname & protocol for your site e.g. "https://mmistakes.github.io"
baseurl : # the subpath of your site, e.g. "/blog"

# Defaults
defaults:
# _posts
- scope:
path: ""
type: posts
values:
layout: single
author_profile: true
read_time: false
comments: true
share: true
related: false
# _pages
- scope:
path: ""
type: pages
values:
layout: single
author_profile: true
related: true

那么,我该怎么做呢?我真的不擅长 html 和 jekyll 的东西。

最佳答案

如前所述here ,以下应该有效:

{% for post in site.categories.android %}
{% include archive-single.html %}
{% endfor %}

类别声明如下:

categories: android third-party

关于html - 如何使用 jekyll 按时间顺序在 _posts 的子目录中列出我的帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39346102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com