You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/07/25 19:24:39 UTC
[sling-site] 01/01: SLING-10668 add edit link to each page
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/SLING-10668-edit-link
in repository https://gitbox.apache.org/repos/asf/sling-site.git
commit 02e8a2643e0d6280d931e851e44f11ce9cee4009
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Jul 25 21:24:24 2021 +0200
SLING-10668 add edit link to each page
This open the MD source file in GitHub editor
---
src/main/jbake/templates/edit-brick.tpl | 8 ++++++++
src/main/jbake/templates/layout/main.tpl | 1 +
src/main/jbake/templates/page.tpl | 3 +++
3 files changed, 12 insertions(+)
diff --git a/src/main/jbake/templates/edit-brick.tpl b/src/main/jbake/templates/edit-brick.tpl
new file mode 100644
index 0000000..dd42d3a
--- /dev/null
+++ b/src/main/jbake/templates/edit-brick.tpl
@@ -0,0 +1,8 @@
+div(class:"edit") {
+ def prefix = 'https://github.com/apache/sling-site/edit/master/src/main/jbake/'
+ // relativize absolute content.file path
+ def relativeSourcePath = config.sourceFolder.toPath().relativize(java.nio.file.Paths.get(content.file))
+ a(href:"${prefix}${relativeSourcePath}") {
+ yield "Edit"
+ }
+}
\ No newline at end of file
diff --git a/src/main/jbake/templates/layout/main.tpl b/src/main/jbake/templates/layout/main.tpl
index 61def05..be9af0c 100644
--- a/src/main/jbake/templates/layout/main.tpl
+++ b/src/main/jbake/templates/layout/main.tpl
@@ -15,6 +15,7 @@ html(lang:'en'){
div(class:"level") {
div(class:"pagenav") {
breadcrumbs()
+ edit()
}
tags()
}
diff --git a/src/main/jbake/templates/page.tpl b/src/main/jbake/templates/page.tpl
index 099e103..92da66b 100644
--- a/src/main/jbake/templates/page.tpl
+++ b/src/main/jbake/templates/page.tpl
@@ -6,6 +6,9 @@ layout 'layout/main.tpl', true,
breadcrumbs : contents {
include template : 'breadcrumbs-brick.tpl'
},
+ edit : contents {
+ include template : 'edit-brick.tpl'
+ },
tableOfContents : contents {
include template : 'toc-brick.tpl'
},