Automate sidebar listings

This commit is contained in:
Lea Verou
2025-01-03 15:52:58 -05:00
parent 2a957e6316
commit fa094d924d
4 changed files with 53 additions and 117 deletions

View File

@@ -0,0 +1,18 @@
<wa-details {{ 'open' if ('/' + tag + '/') in page.url }}>
<h2 slot="summary">
{% set groupUrl %}/docs/{{ tag }}/{% endset %}
{% if groupUrl | getCollectionItemFromUrl %}
<a href="{{ groupUrl }}" title="Overview">{{ title or (tag | capitalize) }}
<wa-icon name="grid-2"></wa-icon>
</a>
{% else %}
{{ title or (tag | capitalize) }}
{% endif %}
</h2>
<ul>
{% for page in collections[tag] | sort %}
{% include 'sidebar-link.njk' %}
{% endfor %}
</ul>
</wa-details>

View File

@@ -0,0 +1,16 @@
{% if not (isAlpha and page.data.noAlpha) and page.fileSlug != tag and not page.unlisted -%}
<li>
<a href="/docs/{{ tag }}/{{ page.fileSlug }}">{{ page.data.title }}</a>
{% if page.data.status == 'experimental' %}<wa-icon name="flask"></wa-icon>{% endif %}
{% if page.data.isPro %}<wa-badge class="pro">PRO</wa-badge>{% endif %}
{% set children = page.data.children %}
{% if children.length > 0 %}
<ul>
{% for page in children %}
{% include 'sidebar-link.njk' %}
{% endfor %}
</ul>
{% endif %}
</li>
{%- endif %}

View File

@@ -19,121 +19,13 @@
<li><a href="/docs/resources/changelog">Changelog</a></li>
</ul>
{# Components #}
<wa-details {{ 'open' if '/components/' in page.url }}>
<h2 slot=summary>
<a href="/docs/components/" title="Overview">Components
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for component in collections.components | sort %}
{% if not component.data.parent and not (isAlpha and component.data.noAlpha) and not component.data.unlisted %}
<li>
<a href="/docs/components/{{ component.fileSlug }}">{{ component.data.title }}</a>
{% if components[component.fileSlug].status == 'experimental' %}<wa-icon name="flask"></wa-icon>{% endif %}
{% if component.data.isPro %}<wa-badge class="pro">PRO</wa-badge>{% endif %}
<ul>
{% for child in collections.components | sort %}
{% if child.data.parent == component.fileSlug and not (isAlpha and child.data.noAlpha) %}
<li>
<a href="/docs/components/{{ child.fileSlug }}">{{ child.data.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
</wa-details>
<wa-details {{ 'open' if '/native/' in page.url }}>
<h2 slot=summary>
<a href="/docs/native/" title="Overview">Native Styles
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for page in collections.native | sort %}
{% if page.fileSlug != 'native' and not page.unlisted %}
<li>
<a href="/docs/native/{{ page.fileSlug }}">{{ page.data.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</wa-details>
<wa-details {{ 'open' if '/utilities/' in page.url }}>
<h2 slot=summary>
<a href="/docs/utilities/" title="Overview">Style Utilities
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for page in collections.utilities | sort %}
{% if page.fileSlug != 'utilities' and not page.unlisted %}
<li>
<a href="/docs/utilities/{{ page.fileSlug }}">{{ page.data.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
</wa-details>
{# Layout #}
<h2>
<a href="/docs/layout" title="Overview">Layout
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for page in collections.layout | sort %}
{% if page.fileSlug != 'layout' and not page.unlisted %}
<li>
<a href="{{ page.url }}">{{ page.data.title }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
{# Patterns #}
{% if not isAlpha %}
<h2>Patterns</h2>
<ul>
<li><a href="/docs/patterns/app">Web App</a></li>
<li><a href="/docs/patterns/ecommerce">E-commerce</a>
<ul>
<li><a href="/docs/patterns/ecommerce-product-review">Product Reviews</a></li>
<li><a href="/docs/patterns/ecommerce-product-list">Product Lists</a></li>
<li><a href="/docs/patterns/ecommerce-category-preview">Category Previews</a></li>
<li><a href="/docs/patterns/ecommerce-shopping-cart">Shopping Carts</a></li>
<li><a href="/docs/patterns/ecommerce-category-filter">Category Filters</a></li>
<li><a href="/docs/patterns/ecommerce-product-detail">Product Detail</a></li>
<li><a href="/docs/patterns/ecommerce-order-summary">Order Summaries</a></li>
<li><a href="/docs/patterns/ecommerce-order-history">Order History</a></li>
</ul>
</li>
<li><a href="/docs/patterns/blog">Blog</a></li>
<li><a href="/docs/patterns/news">News</a></li>
</ul>
{% endif %}
{# Theming #}
<h2>
<a href="/docs/theming" title="Overview">Theming
<wa-icon name="grid-2"></wa-icon>
</a>
</h2>
<ul>
{% for page in collections.theming | sort %}
{% if page.fileSlug != 'theming' and not page.unlisted %}
<li>
<a href="/docs/theming/{{ page.fileSlug }}">{{ page.data.title }}</a>
</li>
{% endif %}
{% for tag, title in {
'components': 'Components',
'native': 'Native Styles',
'utilities': 'Style Utilities',
'layout': 'Layout',
'patterns': 'Patterns',
'theming': 'Theming'
} %}
{% include 'sidebar-group.njk' %}
{% endfor %}
</ul>