<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>{{garden_title}} - {{page_title}}</title>
    <link href="https://necolas.github.io/normalize.css/8.0.1/normalize.css" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link
        href="https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,400;0,700;1,400;1,700&display=swap"
        rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@200;400;700&display=swap" rel="stylesheet">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="og:site_name" content="{{garden_title}}" />
    <meta property="og:title" content="{{page_title}}" />
    <meta property="og:description" content="{{content | striptags | truncate(length=256)}}" />
    <meta property="og:type" content="article" />
    <meta property="og:url" content="https://{{server_name}}/{{path}}" />
    <meta property="og:image" content="/static/favicon.png" />
    <link rel="shortcut icon" href="/static/favicon.png" type="image/x-icon">
    <link href="/static/main.css" rel="stylesheet">
    <link rel="stylesheet" href="main.css">
</head>

<body>
    <aside>
        <nav>
            <h1><a href="/">{{garden_title}}</a></h1>
            {% if recently_changed %}
                <section>
                    <h2>Recently changed</h2>
                    <ul>
                        {% for file_mtime in recently_changed | slice(end=5) %}
                            <li class="page">
                                <a href="/{{file_mtime.0}}">
                                    <span class="timestamp">{{ file_mtime.1 }}</span>
                                    <span class="filepath">
                                        {% for component in file_mtime.0 | trim_end_matches(pat=".md") | split(pat=".") %}
                                            {%- if not loop.last -%}
                                                <span class="not-last">{{component}}.</span>
                                            {%- else -%}
                                                <span>{{component}}</span>
                                            {%- endif -%}
                                        {% endfor %}
                                    </span>
                                </a>
                            </li>
                        {% endfor %}
                    </ul>
                </section>
            {% endif %}
            <section>
                <h2>All entries</h2>
                <ul>
                    {% for file in files %}
                        {% if file is containing(".md") %}
                            <li class="page">
                                <a href="/{{file}}">
                                    <span class="filepath">
                                        {% for component in file | trim_end_matches(pat=".md") | split(pat=".") %}
                                            {%- if not loop.last -%}
                                                <span class="not-last">{{component}}.</span>
                                            {%- else -%}
                                                <span>{{component}}</span>
                                            {%- endif -%}
                                        {% endfor %}
                                    </span>
                                </a>
                            </li>
                        {% else %}
                            <li class="file"><a href="/{{file}}">{{file}}</a></li>
                        {% endif %}
                    {% endfor %}
                </ul>
            </section>
            {% if tags %}
            <section>
                <h2>Tags</h2>
                <ul>
                    {% for tag_cnt in tags %}
                        <li class="tag">
                            <a href="/{{tag_cnt.0}}">
                                <span class="label">#{{tag_cnt.0}}</span> <span class="count">({{tag_cnt.1}})</span>
                            </a>
                        </li>
                    {% endfor %}
                </ul>
            </section>
            {% endif %}
            <section class="graph-view">
                <a href="/!graph">Graph view (beta)</a>
            </section>
        </nav>
        <footer><a href="https://gitlab.com/tmladek/gardenserver">gardenserver {{version}}</a></footer>
    </aside>
    <main>
        {{content | safe}}

        <hr>

        {% if backlinks %}
        <h1>Linked from:</h1>
        <ul>
            {% for link in backlinks %}
            <li><a href="/{{ link }}">{{link}}</a></li>
            {% endfor %}
        </ul>
        {% endif %}

        {% if mtime %}
            <footer>
                Last modified at {{mtime}}
            </footer>
        {% endif %}
    </main>
</body>

</html>