website

#astro#js#html#css

git clone https://git.pyrossh.dev/website

木 Personal website of pyrossh. Built with astrojs, shiki, vite.


src/_includes/file-tree.njk
{% macro renderNodes(nodes, repoId, activePath) %}
<ul>
  {% for node in nodes %}
    {% if node.isDirectory %}
    <li>
      <details {% if node.path | isAncestorDir(activePath) %}open{% endif %}>
        <summary>{{ node.name | folderIcon | safe }}{{ node.name }}/</summary>
        {{ renderNodes(node.children, repoId, activePath) }}
      </details>
    </li>
    {% else %}
    {% set href = "/repos/" + repoId + "/files/" + node.path + "/" %}
    <li>
      <a
        href="{{ href }}"
        hx-get="{{ href }}"
        hx-select="#file-pane"
        hx-target="#file-pane"
        hx-swap="outerHTML"
        hx-push-url="true"
        class="{% if node.path == activePath %}active-file{% endif %}"
      >{{ node.name | fileIcon(node.ext) | safe }}{{ node.name }}<span class="file-size">{{ node.size | formatBytes }}</span></a>
    </li>
    {% endif %}
  {% endfor %}
</ul>
{% endmacro %}