Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adding /en to 'edit this page' link when content isn't in language subdirectory #296

Closed
okohll opened this issue Jun 23, 2020 · 3 comments
Closed

Comments

@okohll
Copy link
Contributor

okohll commented Jun 23, 2020

From discussion here: https://groups.google.com/g/docsy-users/c/ls-rid22fSU

We have a single language site, where the content is not in a language subdirectory. In config.toml, defaultContentLanguageInSubdir = false.

The 'edit this page' link still contains the /en element.

e.g. on https://docs.agilebase.co.uk/docs/tiles/, the Edit This Page link goes to

https://github.com/okohll/abdocs/edit/master/content/en/introduction/scaling-potential.md

whereas it should go to

https://github.com/okohll/abdocs/edit/master/content/introduction/scaling-potential.md


May be the same as #138
Source repo: https://github.com/okohll/abdocs/
Publish repo: https://github.com/okohll/abdocs-public

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 2, 2020

So I'm trying to figure out a nice solution that works for everyone, but in the meantime you can fix your problem by adding your own version of layouts/partials/page-meta-links.html in your project that never adds the /en:

{{ if .Path }}
{{ $pathFormatted := replace .Path "\\" "/" }}
{{ $gh_repo := ($.Param "github_repo") }}
{{ $gh_subdir := ($.Param "github_subdir") }}
{{ $gh_project_repo := ($.Param "github_project_repo") }}
{{ $gh_branch := (default "master" ($.Param "github_branch")) }}
{{ if $gh_repo }}
<div class="td-page-meta ml-2 pb-1 pt-2 mb-0">
{{ $editURL := printf "%s/edit/%s/content/%s" $gh_repo $gh_branch $pathFormatted }}
{{ if $gh_subdir }}
{{ $editURL = printf "%s/edit/%s/%s/content/%s" $gh_repo $gh_branch $gh_subdir $pathFormatted }}
{{ end }}
{{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (htmlEscape $.Title )}}
<a href="{{ $editURL }}" target="_blank"><i class="fa fa-edit fa-fw"></i> {{ T "post_edit_this" }}</a>
<a href="{{ $issuesURL }}" target="_blank"><i class="fab fa-github fa-fw"></i> {{ T "post_create_issue" }}</a>
{{ if $gh_project_repo }}
{{ $project_issueURL := printf "%s/issues/new" $gh_project_repo }}
<a href="{{ $project_issueURL }}" target="_blank"><i class="fas fa-tasks fa-fw"></i> {{ T "post_create_project_issue" }}</a>
{{ end }}
</div>
{{ end }}
{{ end }}

I'll mark this as a duplicate of #138 as it seems to be the same problem.

@LisaFC
Copy link
Collaborator

LisaFC commented Jul 2, 2020

Duplicate of #138

@LisaFC LisaFC marked this as a duplicate of #138 Jul 2, 2020
@okohll
Copy link
Contributor Author

okohll commented Jul 3, 2020

Great, that works, thanks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants