Skip to content

Instantly share code, notes, and snippets.

@WithdewHua
Last active October 4, 2018 13:55
Show Gist options
  • Save WithdewHua/152877ed9461c71caeb5571ccb80248c to your computer and use it in GitHub Desktop.
Save WithdewHua/152877ed9461c71caeb5571ccb80248c to your computer and use it in GitHub Desktop.
shortcodes
---
layout: page
title : Archives
description: "冰冻三尺,非一日之寒。"
header-img: "img/archive-bg.jpg"
---
{% for post in site.posts %}
{% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
{% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %}
{% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}
{% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %}
{% if forloop.first %}
<legend id="{{this_year}}-{{this_month}}">{{this_year}} {{this_month}}</legend>
<ul>
{% endif %}
<li><span>{{ post.date | date: "%F" }}</span> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
{% if forloop.last %}
</ul>
{% else %}
{% if this_year != next_year %}
</ul>
<legend id="{{next_year}}-{{next_month}}">{{next_year}} {{next_month}}</legend>
<ul>
{% else %}
{% if this_month != next_month %}
</ul>
<legend id="{{next_year}}-{{next_month}}">{{next_year}} {{next_month}}</legend>
<ul>
{% endif %}
{% endif %}
{% endif %}
{% endfor%}
{% assign posts_collate = nil %}
# gist
{{< gist username project_name >}}
{{< gist username project_name filename >}} // 若一个gist有多段代码,可以在后面加上filename
# instagram /tweet
{{< instagram/tweet post_id >}}
# youtube
{{< youtube video_id >}} // Positional
{{< youtube id="video_id" autoplay="true" >}} // Named
---
layout: null
sitemap:
exclude: 'yes'
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in site.posts %}
{% unless post.published == false %}
<url>
<loc>{{ site.url }}{{ post.url }}</loc>
{% if post.sitemap.lastmod %}
<lastmod>{{ post.sitemap.lastmod | date: "%Y-%m-%d" }}</lastmod>
{% elsif post.date %}
<lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
{% else %}
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
{% endif %}
{% if post.sitemap.changefreq %}
<changefreq>{{ post.sitemap.changefreq }}</changefreq>
{% else %}
<changefreq>monthly</changefreq>
{% endif %}
{% if post.sitemap.priority %}
<priority>{{ post.sitemap.priority }}</priority>
{% else %}
<priority>0.5</priority>
{% endif %}
</url>
{% endunless %}
{% endfor %}
{% for page in site.pages %}
{% unless page.sitemap.exclude == "yes" %}
<url>
<loc>{{ site.url }}{{ page.url | remove: "index.html" }}</loc>
{% if page.sitemap.lastmod %}
<lastmod>{{ page.sitemap.lastmod | date: "%Y-%m-%d" }}</lastmod>
{% elsif page.date %}
<lastmod>{{ page.date | date_to_xmlschema }}</lastmod>
{% else %}
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
{% endif %}
{% if page.sitemap.changefreq %}
<changefreq>{{ page.sitemap.changefreq }}</changefreq>
{% else %}
<changefreq>monthly</changefreq>
{% endif %}
{% if page.sitemap.priority %}
<priority>{{ page.sitemap.priority }}</priority>
{% else %}
<priority>0.3</priority>
{% endif %}
</url>
{% endunless %}
{% endfor %}
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment