Browse Source

feat: add caddy redirects

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
master
Henrique Dias 1 year ago
commit
07d586705e
3 changed files with 16 additions and 0 deletions
  1. +6
    -0
      config.yaml
  2. +3
    -0
      go.mod
  3. +7
    -0
      layouts/index.redir.txt

+ 6
- 0
config.yaml View File

@ -0,0 +1,6 @@
outputFormats:
redir:
mediaType: text/plain
baseName: redirects
isPlainText: true
notAlternative: true

+ 3
- 0
go.mod View File

@ -0,0 +1,3 @@
module github.com/hacdias/hugo-caddy-redirs
go 1.13

+ 7
- 0
layouts/index.redir.txt View File

@ -0,0 +1,7 @@
{{- range $p := .Site.Pages -}}
{{ range .Aliases }}
{{- $trimmed := ( strings.TrimSuffix "/" ( strings.TrimPrefix "/" . ) ) -}}
/{{ $trimmed }} {{ $p.RelPermalink }}
/{{ $trimmed }}/ {{ $p.RelPermalink -}}
{{ end -}}
{{- end -}}

Loading…
Cancel
Save