Skip to content

Commit d6589e0

Browse files
author
Tim Bannister
committed
Omit “Edit this page” links for generated content
Copy the page meta links template from the Docsy theme, and adapt it to only suggest editing pages that aren't autogenerated.
1 parent 9fd3fea commit d6589e0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

layouts/partials/page-meta-links.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{/* template adapted from Docsy theme */}}
2+
{{ if .Path }}
3+
{{ $pathFormatted := replace .Path "\\" "/" }}
4+
{{ $gh_repo := ($.Param "github_repo") }}
5+
{{ $gh_subdir := ($.Param "github_subdir") }}
6+
{{ $gh_project_repo := ($.Param "github_project_repo") }}
7+
{{ $gh_branch := (default "master" ($.Param "github_branch")) }}
8+
<div class="td-page-meta ml-2 pb-1 pt-2 mb-0">
9+
{{ if $gh_repo }}
10+
{{ $gh_repo_path := printf "%s/content/%s" $gh_branch $pathFormatted }}
11+
{{ if and ($gh_subdir) (.Site.Language.Lang) }}
12+
{{ $gh_repo_path = printf "%s/%s/content/%s/%s" $gh_branch $gh_subdir ($.Site.Language.Lang) $pathFormatted }}
13+
{{ else if .Site.Language.Lang }}
14+
{{ $gh_repo_path = printf "%s/content/%s/%s" $gh_branch ($.Site.Language.Lang) $pathFormatted }}
15+
{{ else if $gh_subdir }}
16+
{{ $gh_repo_path = printf "%s/%s/content/%s" $gh_branch $gh_subdir $pathFormatted }}
17+
{{ end }}
18+
{{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path }}
19+
{{ $createURL := printf "%s/edit/%s" $gh_repo $gh_repo_path }}
20+
{{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (htmlEscape $.Title )}}
21+
{{ $newPageStub := resources.Get "stubs/new-page-template.md" }}
22+
{{ $newPageQS := querify "value" $newPageStub.Content "filename" "change-me.md" | safeURL }}
23+
{{ $newPageURL := printf "%s/new/%s?%s" $gh_repo $gh_repo_path $newPageQS }}
24+
25+
{{ if not (.Param "auto_generated") }}
26+
<a href="{{ $editURL }}" target="_blank"><i class="fa fa-edit fa-fw"></i> {{ T "post_edit_this" }}</a>
27+
<a href="{{ $newPageURL }}" target="_blank"><i class="fa fa-edit fa-fw"></i> {{ T "post_create_child_page" }}</a>
28+
{{ end }}
29+
30+
<a href="{{ $issuesURL }}" target="_blank"><i class="fab fa-github fa-fw"></i> {{ T "post_create_issue" }}</a>
31+
{{ if $gh_project_repo }}
32+
{{ $project_issueURL := printf "%s/issues/new" $gh_project_repo }}
33+
<a href="{{ $project_issueURL }}" target="_blank"><i class="fas fa-tasks fa-fw"></i> {{ T "post_create_project_issue" }}</a>
34+
{{ end }}
35+
36+
{{ end }}
37+
{{ with .CurrentSection.AlternativeOutputFormats.Get "print" }}
38+
<a id="print" href="{{ .Permalink | safeURL }}"><i class="fa fa-print fa-fw"></i> {{ T "print_entire_section" }}</a>
39+
{{ end }}
40+
</div>
41+
{{ end }}

0 commit comments

Comments
 (0)