-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MkDocs sitemap to not skip section index pages
Fixes #3
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# https://github.com/mkdocs/mkdocs/blob/cb85d48851133e6d482deb3405de67c3dbea82be/mkdocs/templates/sitemap.xml | ||
input: | | ||
{%- macro nav_item(item) -%} | ||
{%- if item.children -%} | ||
{%- for child in item.children -%} | ||
{{ nav_item(child) }} | ||
{%- endfor -%} | ||
{%- else %} | ||
{%- if not item.is_link -%} | ||
<url> | ||
<loc>{% if item.canonical_url %}{{ item.canonical_url|e }}{% else %}{{ item.abs_url|e }}{% endif %}</loc> | ||
{% if item.update_date %}<lastmod>{{item.update_date}}</lastmod>{% endif %} | ||
<changefreq>daily</changefreq> | ||
</url> | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endmacro -%} | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
{%- for item in nav -%} | ||
{{ nav_item(item) }} | ||
{%- endfor %} | ||
</urlset> | ||
output: | | ||
{%- macro nav_item(item) -%} | ||
{%- if item.children -%} | ||
{%- for child in item.children -%} | ||
{{ nav_item(child) }} | ||
{%- endfor -%} | ||
{%- endif %}{% if item.url %} | ||
{%- if not item.is_link -%} | ||
<url> | ||
<loc>{% if item.canonical_url %}{{ item.canonical_url|e }}{% else %}{{ item.abs_url|e }}{% endif %}</loc> | ||
{% if item.update_date %}<lastmod>{{item.update_date}}</lastmod>{% endif %} | ||
<changefreq>daily</changefreq> | ||
</url> | ||
{%- endif -%} | ||
{%- endif -%} | ||
{%- endmacro -%} | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
{%- for item in nav -%} | ||
{{ nav_item(item) }} | ||
{%- endfor %} | ||
</urlset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters