{{ $content := .content }}
{{ $page := .page }}
{{ $wikilinks := findRE `\[\[(.*?)\]\]` $content -1 }}

{{ range $wikilinks }}
  {{ $original := . }}
  {{ $inner := strings.TrimPrefix "[[" (strings.TrimSuffix "]]" $original) }}
  
  {{ $target := $inner }}
  {{ $display := $inner }}
  
  {{ if strings.Contains $inner "|" }}
    {{ $parts := split $inner "|" }}
    {{ $target = trim (index $parts 0) " " }}
    {{ $display = trim (index $parts 1) " " }}
  {{ end }}
  
  {{ $found := false }}
  {{ $matchedPage