From ae3645d3a1233218b7c7aad3e0bdaf259b84d238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aurimas=20Bla=C5=BEulionis?= <0x60@pm.me> Date: Mon, 4 Dec 2023 21:34:27 +0200 Subject: [PATCH] Add backlink generation --- main.py | 19 +++++++++++++++---- src/styles.scss | 8 ++++---- templates/main.html | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 36ae5d9..4db47f3 100644 --- a/main.py +++ b/main.py @@ -15,10 +15,10 @@ # Define custom variables passed over to the templates template_vars = { 'navbar': [ - ('/', 'Home'), - ('/about', 'About'), - ('/quick_start', 'Quick start guide'), - ('/docs', 'Documentation'), + ('', 'Home'), + ('about', 'About'), + ('quick_start', 'Quick start guide'), + ('docs', 'Documentation'), ] } @@ -50,6 +50,17 @@ pre += '/index' of = pre + ".html" os.makedirs(os.path.dirname(of), exist_ok=True) + + # Build a backlink to root + offset2 = of[len(out_dir):] + if offset2.startswith('/'): + offset2 = offset2[1:] + backlink = '' + for i in range(1,len(offset2.split("/"))): + backlink += '../' + + template_vars['backlink'] = backlink + content = str.encode(template.render(template_vars, content=content.decode('utf-8'))) elif ext == '.scss': of = pre + ".css" diff --git a/src/styles.scss b/src/styles.scss index 70f5478..31d6615 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -27,7 +27,7 @@ body { .logo { display: inline-block; text-align: left; - color: $logo; + color: $logo; } .root { @@ -50,11 +50,11 @@ body { margin: 30px; width: calc(min(90vw, max(50vw, 20cm))); max-width: calc(max(60vw, 30cm)); - doverflow: hidden; + doverflow: hidden; } .content img { - max-width: 100%; + max-width: 100%; } // Github users @@ -163,7 +163,7 @@ h4 { background-color: #1e1e1e; pre { padding: 7px; - margin: 0; + margin: 0; overflow: scroll; overflow-x: auto; overflow-y: hidden; diff --git a/templates/main.html b/templates/main.html index eba43ed..2403773 100644 --- a/templates/main.html +++ b/templates/main.html @@ -5,7 +5,7 @@
|{% endif %}