Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ For a list of issues targeted for the next release, see the [23Q1][] milestone.

- Non-breaking changes that result from the Bootstrap v5 upgrade:
- Draw.io diagram edit button: replaced custom colors by BS's outline primary.
- Fix page meta links for single language pages ([#138])

[#138]: https://github.com/google/docsy/issues/138
[#470]: https://github.com/google/docsy/issues/470
[#906]: https://github.com/google/docsy/issues/906
[#939]: https://github.com/google/docsy/issues/939
Expand Down
10 changes: 3 additions & 7 deletions layouts/partials/page-meta-links.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
{{ warnf "Warning: use of `github_url` is deprecated. For details see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}}
<a href="{{ $gh_url }}" target="_blank"><i class="fa-solid fa-pen-to-square fa-fw"></i> {{ T "post_edit_this" }}</a>
{{ else if $gh_repo -}}
{{ $gh_repo_path := printf "%s/content/%s" $gh_branch $pathFormatted -}}
{{ if and ($gh_subdir) (.Site.Language.Lang) -}}
{{ $gh_repo_path = printf "%s/%s/content/%s/%s" $gh_branch $gh_subdir ($.Site.Language.Lang) $pathFormatted -}}
{{ else if .Site.Language.Lang -}}
{{ $gh_repo_path = printf "%s/content/%s/%s" $gh_branch ($.Site.Language.Lang) $pathFormatted -}}
{{ else if $gh_subdir -}}
{{ $gh_repo_path = printf "%s/%s/content/%s" $gh_branch $gh_subdir $pathFormatted -}}
{{ $gh_repo_path := printf "%s/content/%s" $gh_branch ( relLangURL $pathFormatted ) -}}
Copy link
Copy Markdown
Collaborator

@LisaFC LisaFC Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So (for some reason the GH web UI won't let me comment on any lines outside your change) you need to do the following:

Change line 2 above from

 {{ $pathFormatted := replace .File.Path "\\" "/" -}}

to

{{ $pathFormatted := strings.TrimPrefix hugo.WorkingDir $.File.Filename -}}

Then change these lines to:

  {{ $gh_repo_path := printf "%s%s" $gh_branch $pathFormatted -}}
  {{ if $gh_subdir -}}
    {{ $gh_repo_path = printf "%s/%s%s" $gh_branch $gh_subdir $pathFormatted -}}

That works for both sites with language subdirectories and ones without!

{{ if $gh_subdir -}}
{{ $gh_repo_path = printf "%s/%s/content%s" $gh_branch $gh_subdir ( relLangURL $pathFormatted ) -}}
{{ end -}}

{{/* Adjust $gh_repo_path based on path_base_for_github_subdir */ -}}
Expand Down