Skip to content

Commit 435b2e0

Browse files
authored
Rework and clean up page-meta-links.html + CHANGELOG entry (google#1807)
1 parent c1cad5f commit 435b2e0

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

.vscode/cspell.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
{
33
"version": "0.2",
44
"caseSensitive": true,
5-
"words": ["Docsy", "shortcode", "shortcodes"]
5+
"words": ["Docsy", "hugo", "shortcode", "shortcodes", "warnf"]
66
}

CHANGELOG.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
cSpell:ignore deining docsy gtag lookandfeel navs
2+
cSpell:ignore deining docsy gitmodules gtag lookandfeel mhchem navs tabpane
33
-->
44

55
# Changelog
@@ -25,13 +25,29 @@ For the full list of changes, see the [0.x.y] release notes.
2525

2626
**Breaking changes**:
2727

28-
- ...
28+
- [Repository Links] now work for [multi-language] sites ([#1744]).
29+
30+
For any given page, repository links are now computed from a page's _resolved_
31+
`File` path, as resolved _through_ mount points, if any. That is, the path
32+
used is the one that refers to the file's actual location on disk, not it's
33+
logical path in Hugo's [union file system].
34+
35+
This is a breaking change pages of sites that use mounts and
36+
[path_base_for_github_subdir]. Projects will need to adjust the value of
37+
[path_base_for_github_subdir] to be relative to the file's physical location.
2938

3039
**New**:
3140

3241
**Other changes**:
3342

3443
[0.x.y]: https://github.com/google/docsy/releases/latest?FIXME=v0.X.Y
44+
[#1744]: https://github.com/google/docsy/pull/1744
45+
[multi-language]: https://www.docsy.dev/docs/language/
46+
[path_base_for_github_subdir]:
47+
https://www.docsy.dev/docs/adding-content/repository-links/#path_base_for_github_subdir-optional
48+
[Repository Links]: https://www.docsy.dev/docs/adding-content/repository-links/
49+
[union file system]:
50+
https://gohugo.io/getting-started/directory-structure/#union-file-system
3551

3652
## 0.8.0
3753

layouts/partials/page-meta-links.html

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1+
{{/* cSpell:ignore querify subdir */ -}}
12
{{ if .File -}}
2-
{{ $pathFormatted := strings.TrimPrefix hugo.WorkingDir $.File.Filename -}}
3-
{{ $gh_repo := ($.Param "github_repo") -}}
4-
{{ $gh_url := ($.Param "github_url") -}}
5-
{{ $gh_subdir := ($.Param "github_subdir") -}}
6-
{{ $gh_project_repo := ($.Param "github_project_repo") -}}
7-
{{ $gh_branch := (default "main" ($.Param "github_branch")) -}}
3+
{{ $path := strings.TrimPrefix (add hugo.WorkingDir "/") $.File.Filename -}}
4+
{{ $gh_repo := $.Param "github_repo" -}}
5+
{{ $gh_url := $.Param "github_url" -}}
6+
{{ $gh_subdir := $.Param "github_subdir" | default "" -}}
7+
{{ $gh_project_repo := $.Param "github_project_repo" -}}
8+
{{ $gh_branch := $.Param "github_branch" | default "main" -}}
89
<div class="td-page-meta ms-2 pb-1 pt-2 mb-0">
910
{{ if $gh_url -}}
10-
{{ warnf "Warning: use of `github_url` is deprecated. For details see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}}
11+
{{ warnf "Warning: use of `github_url` is deprecated. For details, see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}}
1112
<a href="{{ $gh_url }}" target="_blank"><i class="fa-solid fa-pen-to-square fa-fw"></i> {{ T "post_edit_this" }}</a>
1213
{{ else if $gh_repo -}}
13-
{{ $gh_repo_path := printf "%s%s" $gh_branch $pathFormatted -}}
14-
{{ if $gh_subdir -}}
15-
{{ $gh_repo_path = printf "%s/%s%s" $gh_branch $gh_subdir $pathFormatted -}}
16-
{{ end -}}
1714

18-
{{/* Adjust $gh_repo_path based on path_base_for_github_subdir */ -}}
15+
{{/* Adjust $path based on path_base_for_github_subdir */ -}}
1916
{{ $ghs_base := $.Param "path_base_for_github_subdir" -}}
2017
{{ $ghs_rename := "" -}}
2118
{{ if reflect.IsMap $ghs_base -}}
2219
{{ $ghs_rename = $ghs_base.to -}}
2320
{{ $ghs_base = $ghs_base.from -}}
2421
{{ end -}}
2522
{{ with $ghs_base -}}
26-
{{ $gh_repo_path = replaceRE . $ghs_rename $gh_repo_path -}}
23+
{{ $path = replaceRE . $ghs_rename $path -}}
2724
{{ end -}}
2825

26+
{{ $gh_repo_path := printf "%s/%s/%s" $gh_branch $gh_subdir $path -}}
27+
{{ $gh_repo_path = replaceRE "//+" "/" $gh_repo_path -}}
28+
2929
{{ $viewURL := printf "%s/tree/%s" $gh_repo $gh_repo_path -}}
3030
{{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path -}}
3131
{{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (safeURL $.Title ) -}}

0 commit comments

Comments
 (0)