2021-04-15 01:37:18 -07:00
|
|
|
{{ $scratch := .scratch }}
|
|
|
|
{{ $scratch.Set "bestLength" -1 }}
|
2023-12-30 13:58:56 -08:00
|
|
|
{{ $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) }}
|
2021-04-15 01:37:18 -07:00
|
|
|
{{ $filePath := .path }}
|
|
|
|
{{ range $module, $props := .submoduleLinks }}
|
|
|
|
{{ $path := index $props "path" }}
|
|
|
|
{{ $bestLength := $scratch.Get "bestLength" }}
|
|
|
|
{{ if and (le $bestLength (len $path)) (hasPrefix $filePath $path) }}
|
|
|
|
{{ $scratch.Set "bestLength" (len $path) }}
|
|
|
|
{{ $scratch.Set "bestUrl" (printf "%s%s" (index $props "url") (strings.TrimPrefix $path $filePath)) }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|