~tobyvin/tobyvin.dev

fd4a0a53946128197a302b539b3fcb3dc5b07754 — Toby Vincent 5 months ago 01e90bc
feat: add custom 404 page and clean up macros
4 files changed, 34 insertions(+), 46 deletions(-)

D docker-compose.yml
A templates/404.html
M templates/index.html
M templates/macros.html
D docker-compose.yml => docker-compose.yml +0 -19
@@ 1,19 0,0 @@
version: "3.8"

services:
  site:
    build:
      context: .
    image: registry.tobyvin.dev/site
    networks:
      - proxy
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.tobyvin.rule=Host(`tobyvin.dev`)
        - traefik.http.routers.tobyvin.entrypoints=websecure
        - traefik.http.services.tobyvin.loadbalancer.server.port=80

networks:
  proxy:
    external: true

A templates/404.html => templates/404.html +9 -0
@@ 0,0 1,9 @@
{% extends "index.html" %}
{% block content %}
  <header>
    <hgroup>
      <h1>Error 404</h1>
      <p>Page not found.</p>
    </hgroup>
  </header>
{% endblock content %}

M templates/index.html => templates/index.html +17 -23
@@ 5,31 5,25 @@
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="robots" content="noindex" />
    {% block title %}
      <title>
        {%- if term -%}
          {{ term.name }} - {{ config.title }}
        {%- elif taxonomy -%}
          {{ taxonomy.name }} - {{ config.title }}
        {%- else -%}
          {% set this = page | default(value=section) %}
          {% set len = this.components | length %}
          {%- if len > 0 -%}
            {{ this.title }} - {{ config.title }}
          {%- else -%}
            {{ config.title }}
          {%- endif -%}
        {%- endif -%}
      </title>
    {% endblock title %}
    <title>
      {% if term or taxonomy %}
        {% set this = term | default(value=taxonomy) %}
        {{ this.name }} -
      {% elif page or section %}
        {% set this = page | default(value=section) %}
        {% set len = this.components | length %}
        {%- if len > 0 %}
          {{ this.title }} -
        {% endif -%}
      {% endif %}
      {{ config.title }}
    </title>
    <meta name="description" content="{{ config.description }}" />
    <meta name="keywords" content="blog" />
    {% block feed %}
      <link rel="alternate"
            type="application/atom+xml"
            title="Atom Feed"
            href="{{ get_url(path="atom.xml", trailing_slash=false) }}" />
    {% endblock feed %}
    <link rel="alternate"
          type="application/atom+xml"
          title="Atom Feed"
          href="{{ get_url(path="atom.xml", trailing_slash=false) }}" />
    <link rel="stylesheet" type="text/css" href="/style.css" />
  </head>
  <body>

M templates/macros.html => templates/macros.html +8 -4
@@ 1,4 1,4 @@
{# misc macros #}
{# render meta links #}
{% macro meta_item(name, href, text) %}
  <tr>
    <td>


@@ 8,11 8,13 @@
      <a href="{{ href }}">{{ text }}</a>
    </td>
  </tr>
{% endmacro nav %}
{% endmacro %}
{# render navbar item #}
{% macro nav_item(name, path) %}
  {% set url = get_url(path=path,trailing_slash=true) %}
  <a {% if url == current_url %}class="active"{% endif %} href={{ url }}>{{ name }}</a>
{% endmacro nav %}
  <a {% if current_url and url == current_url %}class="active"{% endif %} href={{ url }}>{{ name }}</a>
{% endmacro %}
{# render table of contents recursively #}
{% macro toc_item(item, depth=0) %}
  <li>
    <a href="{{ item.permalink | safe }}">{{ item.title }}</a>


@@ 23,6 25,7 @@
    {% endif %}
  </li>
{% endmacro %}
{# render table of contents #}
{% macro toc(toc) %}
  {%- set len = toc | length -%}
  {% if len > 1 %}


@@ 33,6 36,7 @@
    </nav>
  {% endif %}
{% endmacro %}
{# render content header #}
{% macro header(item, link=true) %}
  <header>
    <hgroup>