-
Notifications
You must be signed in to change notification settings - Fork 167
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
26 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,22 @@ | ||
{{- $context := .context -}} | ||
{{- $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 $context.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 = "hx-text-xs hx-font-medium hx-text-gray-500 hover:hx-text-gray-900 dark:hx-text-gray-400 dark:hover:hx-text-gray-100 contrast-more:hx-text-gray-800 contrast-more:dark:hx-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