-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `where` > `location` - Edit link > in a partial
- Loading branch information
Showing
4 changed files
with
25 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{- $editThisPage := (T "editThisPage") | default "Edit this page"}} | ||
{{- $linkClass := "mb-4 block text-xs text-gray-500 ltr:text-right rtl:text-left dark:text-gray-400" -}} | ||
{{- if and (site.Params.editURL.enable) (eq site.Params.editURL.location .source) -}} | ||
{{- $editURL := site.Params.editURL.base | default "" -}} | ||
{{- with .Params.editURL -}} | ||
{{/* if `editURL` is set in the front matter */}} | ||
{{- $editURL = . -}} | ||
{{- else -}} | ||
{{- with .File -}} | ||
{{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}} | ||
{{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}} | ||
{{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}} | ||
{{- $path := replace .Path "\\" "/" -}} | ||
{{- $editURL = urls.JoinPath $editURL $sourceDir $path -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- if eq site.Params.editURL.location "toc" -}} | ||
{{- $linkClass = "text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50" -}} | ||
{{- end -}} | ||
<a class="{{ $linkClass}}" href="{{ $editURL }}" target="_blank" rel="noreferer">{{ $editThisPage }}</a> | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters