1
0
mirror of https://github.com/tabler/tabler.git synced 2026-08-06 11:22:23 +04:00

Add sitemap collection to Eleventy config, update .gitignore for preview-astro, and adjust production environment check in default layout

This commit is contained in:
codecalm
2026-07-14 22:39:14 +02:00
parent e098fdfaa6
commit e534c4fdba
5 changed files with 56 additions and 3 deletions
+10
View File
@@ -37,3 +37,13 @@ demo/
dist/
packages-zip/
.env
sri.json
preview-astro
# TypeScript
*.tsbuildinfo
.tsbuildinfo
# Test coverage
coverage/
__screenshots__/
+14
View File
@@ -0,0 +1,14 @@
---
layout: null
permalink: robots.txt
eleventyExcludeFromCollections: true
---
Sitemap: {% if environment != 'development' %}{{ site.docsUrl }}{% endif %}/sitemap.xml
{% if environment == 'development' %}
User-agent: *
Disallow: /
{% else %}
User-agent: *
Disallow:
{% endif %}
+19
View File
@@ -0,0 +1,19 @@
---
layout: null
permalink: sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for entry in collections.sitemap %}
{% assign path = entry.url | replace: 'index.html', '' %}
{% if path == '/' %}
{% assign path = '' %}
{% endif %}
<url>
<loc>{% if environment != 'development' %}{{ site.docsUrl }}{% endif %}{{ path | xml_escape }}</loc>
<lastmod>{{ entry.last_modified_at | default: 'now' | date_to_xmlschema }}</lastmod>
</url>
{% endfor %}
</urlset>
+11
View File
@@ -28,6 +28,17 @@ export default function (eleventyConfig) {
});
});
eleventyConfig.addCollection('sitemap', collection => {
return [...collection.getFilteredByGlob('./content/**/*.md')].sort((a, b) => {
const isHome = (page) => page.url === '/' || page.url === '/index.html';
if (isHome(a)) return -1;
if (isHome(b)) return 1;
return (a.url || '').localeCompare(b.url || '');
});
});
eleventyConfig.setInputDirectory("content");
eleventyConfig.setOutputDirectory("dist");
+1 -2
View File
@@ -5,8 +5,6 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if environment == 'production' %}
{% assign pageSection = "" %}
{% if page.url contains "/ui/" %}
{% assign pageSection = "UI" %}
@@ -34,6 +32,7 @@
{% endif %}
<title>{{ metaTitle }} | {{ siteName }}</title>
{% if environment == 'production' %}
{% if metaDescription %}<meta name="description" content="{{ metaDescription }}">{% endif %}
<link rel="canonical" href="{{ page.url | absolute_url }}">