summaryrefslogtreecommitdiff
path: root/website/templates
diff options
context:
space:
mode:
authorMo Bitar <76752051+mo8it@users.noreply.github.com>2025-05-23 13:26:52 +0200
committerGitHub <noreply@github.com>2025-05-23 13:26:52 +0200
commit2267f996844475f45a96d9582e0ac0d40b4bce79 (patch)
tree94d0634e928e553ba1071fa405b787efb586e84d /website/templates
parente36dd7a1207ccf940ba820abc276fa465f45b531 (diff)
parentbf74a3d0a7ae3c0d12ba572fe1c2f1d711c6e530 (diff)
Merge pull request #2247 from rust-lang/website
Website
Diffstat (limited to 'website/templates')
-rw-r--r--website/templates/404.html14
-rw-r--r--website/templates/anchor-link.html2
-rw-r--r--website/templates/base.html92
-rw-r--r--website/templates/index.html9
-rw-r--r--website/templates/page.html39
-rw-r--r--website/templates/shortcodes/details.html9
6 files changed, 165 insertions, 0 deletions
diff --git a/website/templates/404.html b/website/templates/404.html
new file mode 100644
index 0000000..eb9d469
--- /dev/null
+++ b/website/templates/404.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <div class="flex flex-col mx-auto text-center">
+ <h1>DON'T PANIC!</h1>
+ <h2>404: Page not found!</h2>
+
+ <img class="mx-auto max-h-[50vh]"
+ src="{{ get_url(path='images/panic.svg') | safe }}"
+ alt="">
+
+ <a class="text-2xl font-bold" href="{{ get_url(path='@/_index.md') }}">Back to homepage</a>
+ </div>
+{% endblock %}
diff --git a/website/templates/anchor-link.html b/website/templates/anchor-link.html
new file mode 100644
index 0000000..c8644d9
--- /dev/null
+++ b/website/templates/anchor-link.html
@@ -0,0 +1,2 @@
+<a class="text-white no-underline transition-none hover:underline"
+ href="#{{ id }}"></a>
diff --git a/website/templates/base.html b/website/templates/base.html
new file mode 100644
index 0000000..1a55aeb
--- /dev/null
+++ b/website/templates/base.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+ {%- set timestamp = now(timestamp=true) -%}
+
+ {%- if page.title -%}
+ {% set_global title = page.title %}
+ {%- elif section.title -%}
+ {% set_global title = section.title %}
+ {%- else -%}
+ {% set_global title = config.title %}
+ {%- endif -%}
+
+ {%- if page.description -%}
+ {% set_global description = page.description %}
+ {%- elif section.description -%}
+ {% set_global description = section.description %}
+ {%- else -%}
+ {% set_global description = config.description %}
+ {%- endif -%}
+
+ {%- if page.permalink -%}
+ {% set_global permalink = page.permalink %}
+ {%- elif section.permalink -%}
+ {% set_global permalink = section.permalink %}
+ {%- endif %}
+
+ <title>{%- block title -%}{{- title -}}{%- endblock -%}</title>
+
+ <meta name="description"
+ content="{%- block description -%}{{- description -}}{%- endblock -%}">
+
+ <link rel="icon"
+ type="image/x-icon"
+ href="{{ get_url(path=config.extra.logo_path) | safe }}?v={{ timestamp }}">
+
+ <link href="{{ get_url(path='main.css') | safe }}?v={{ timestamp }}"
+ rel="stylesheet">
+
+ <meta property="og:title" content="{{ title }}">
+ <meta property="og:description" content="{{ description }}">
+ <meta property="og:image"
+ content="{{ get_url(path=config.extra.logo_path) | safe }}?v={{ timestamp }}">
+ {% if permalink %}<meta property="og:url" content="{{ permalink | safe }}">{% endif %}
+ </head>
+
+ <body class="flex flex-col p-2 mx-auto min-h-screen text-lg text-white break-words lg:px-5 2xl:container bg-[#2A3439]">
+ <header class="flex flex-col gap-x-4 items-center py-2 px-4 mb-1 rounded-sm sm:flex-row sm:rounded-full bg-black/30">
+ <a class="transition duration-500 hover:scale-110"
+ href="{{ get_url(path='@/_index.md') | safe }}"
+ aria-hidden="true">
+ <img class="w-12 h-12"
+ src="{{ get_url(path=config.extra.logo_path) | safe }}"
+ alt="">
+ </a>
+
+ <nav class="flex flex-col gap-x-6 items-center font-bold sm:flex-row">
+ {% for menu_item in config.extra.menu_items %}
+ {%- if menu_item.url is starting_with("@") -%}
+ {% set_global menu_item_url = get_url(path=menu_item.url) %}
+ {%- else -%}
+ {% set_global menu_item_url = menu_item.url %}
+ {%- endif %}
+
+ <a class="p-1 no-underline" href="{{ menu_item_url | safe }}">{{ menu_item.name }}</a>
+ {% endfor %}
+ </nav>
+ </header>
+
+ <main class="leading-relaxed">
+ {% block content %}{% endblock %}
+ </main>
+
+ <footer class="pt-2 pb-1 mt-auto text-sm text-center">
+ <div class="inline-flex gap-x-1.5 items-center mx-auto mt-2">
+ <img class="w-8 h-8"
+ src="{{ get_url(path='images/rust_logo.svg') | safe }}"
+ alt="">
+ <div class="italic">Rustlings is an official Rust project</div>
+ </div>
+
+ <nav class="flex flex-col gap-y-3 justify-around py-3 mt-3 rounded-sm sm:flex-row sm:rounded-full bg-black/30">
+ {% for footer_item in config.extra.footer_items %}
+ <a class="no-underline" href="{{ footer_item.url | safe }}">{{ footer_item.name }}</a>
+ {% endfor %}
+ </nav>
+ </footer>
+ </body>
+</html>
diff --git a/website/templates/index.html b/website/templates/index.html
new file mode 100644
index 0000000..0d2b2e3
--- /dev/null
+++ b/website/templates/index.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <div class="m-3">
+ <h1>Rustlings</h1>
+
+ {{ section.content | safe }}
+ </div>
+{% endblock %}
diff --git a/website/templates/page.html b/website/templates/page.html
new file mode 100644
index 0000000..b2f6c01
--- /dev/null
+++ b/website/templates/page.html
@@ -0,0 +1,39 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <article>
+ <h1>{{ page.title }}</h1>
+
+ <div class="py-0.5 px-4 my-3 rounded-xl border-double border-s-4">
+ <nav>
+ <ul class="ml-0 list-none">
+ {% for parent in page.toc %}
+ {% if parent.level == 2 %}
+ <li>
+ {#- -#}
+ <a href="{{ parent.permalink | safe }}">{{ parent.title }}</a>
+ {#- -#}
+ {% if parent.children %}
+ <ul class="my-0 ml-5 list-none">
+ {% for child in parent.children %}
+ {% if child.level == 3 %}
+ <li>
+ {#- -#}
+ <a class="text-base" href="{{ child.permalink | safe }}">{{ child.title }}</a>
+ {#- -#}
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ {% endif %}
+ {#- -#}
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ </nav>
+ </div>
+
+ {{ page.content | safe }}
+ </article>
+{% endblock %}
diff --git a/website/templates/shortcodes/details.html b/website/templates/shortcodes/details.html
new file mode 100644
index 0000000..1c07778
--- /dev/null
+++ b/website/templates/shortcodes/details.html
@@ -0,0 +1,9 @@
+<details>
+ <summary>
+ <strong>{{ summary | safe }}</strong> (<em>click to expand</em>)
+ </summary>
+
+ <blockquote class="pt-1 mx-0.5 mt-1 rounded-none border-dashed border-x-3 border-b-3">
+ {{ body | markdown | safe }}
+ </blockquote>
+</details>