Skip to content

Commit 215be8b

Browse files
committed
Make backlink work with absolute urls
1 parent f3f383b commit 215be8b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
src_dir = 'src'
99
out_dir = 'output'
1010

11+
def linkup(a, b):
12+
if '://' in a:
13+
return a
14+
else:
15+
return b + a
16+
1117
env = Environment(loader=FileSystemLoader('templates'))
1218
env.filters['markdown'] = markdown
19+
env.filters['linkup'] = linkup
1320
template = env.get_template('main.html')
1421

1522
# Define custom variables passed over to the templates

templates/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/_/ /_/ /_/\___/_/ /_/ /_/_/ /_/\____/|__/|__/</pre>
1919
<ul class="navbar">
2020
{% for link, title in navbar %}
21-
<a href="{{ backlink }}{{ link }}">{{ title }}</a>
21+
<a href="{{ link | linkup(backlink) }}">{{ title }}</a>
2222
{%- if not loop.last %}
2323
<pre> | </pre>
2424
{% endif %}

0 commit comments

Comments
 (0)