Skip to content

Commit d28564e

Browse files
author
Tony Wasserka
committed
Add script to fix anchors
1 parent 30c76b6 commit d28564e

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

03_fix_relative_links.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
shopt -s globstar
4+
for i in content/**/*.md
5+
do
6+
# Fix anchor links: Must be converted to lowercase
7+
sed -i -e 's/\(\[.*\](\)\(#.* "wikilink")\)/\1\L\2/g' $i
8+
9+
# # Fix relative links: Must prepend / on any non-anchor link
10+
# perl -0777 -i -pe 's/(\[(?s:.)*?\])\(([^#].* "wikilink"\))/\1(\/\2/g' $i
11+
12+
# TODO: Remove colons from relative link targets
13+
done

config/_default/config.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
baseURL = ''
1+
baseURL = 'https://mikage-emu.github.io/3dbrew/'
22
languageCode = 'en-us'
33
title = '3dbrew'
44
disablePathToLower = true
5+
6+
# Broken, see https://github.com/gohugoio/hugo/issues/12130
7+
# relativeURLs = true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if (not (or (strings.HasPrefix .Destination "http") (strings.HasPrefix .Destination "#"))) }}
2+
<a href="/3dbrew/{{ .Destination }}"
3+
{{- with .Title }} title="{{ . }}"{{ end -}}
4+
>
5+
{{- with .Text }}{{ . }}{{ end -}}
6+
</a>
7+
{{ else }}
8+
<a href="{{ .Destination | safeURL }}"
9+
{{- with .Title }} title="{{ . }}"{{ end -}}
10+
>
11+
{{- with .Text }}{{ . }}{{ end -}}
12+
</a>
13+
{{ end -}}

0 commit comments

Comments
 (0)