From 75717374a849864e2eb911312fcb6baf65bee135 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 17 Jun 2021 14:56:27 -0400 Subject: [PATCH] feat(sidebar): Add sidebar support --- README.md | 6 ++++++ main.go | 10 ++++++---- pkg/mark/meta.go | 6 ++++++ pkg/mark/stdlib/stdlib.go | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index db3bdd3..9c0a69b 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,12 @@ Also, optional following headers are supported: * (default) page: normal Confluence page - defaults to this if omitted * blogpost: [Blog post](https://confluence.atlassian.com/doc/blog-posts-834222533.html) in `Space`. Cannot have `Parent`(s) +```markdown + +``` + +Setting the sidebar creates a column on the right side. You're able to add any valid HTML content. Adding this property sets the layout to `article`. + Mark supports Go templates, which can be included into article by using path to the template relative to current working dir, e.g.: diff --git a/main.go b/main.go index db84959..d481c10 100644 --- a/main.go +++ b/main.go @@ -299,11 +299,13 @@ func processFile( &buffer, "ac:layout", struct { - Layout string - Body string + Layout string + Sidebar string + Body string }{ - Layout: meta.Layout, - Body: html, + Layout: meta.Layout, + Sidebar: meta.Sidebar, + Body: html, }, ) if err != nil { diff --git a/pkg/mark/meta.go b/pkg/mark/meta.go index d998d03..3cc6d51 100644 --- a/pkg/mark/meta.go +++ b/pkg/mark/meta.go @@ -19,6 +19,7 @@ const ( HeaderAttachment = `Attachment` HeaderLabel = `Label` HeaderInclude = `Include` + HeaderSidebar = `Sidebar` ) type Meta struct { @@ -27,6 +28,7 @@ type Meta struct { Type string Title string Layout string + Sidebar string Attachments map[string]string Labels []string } @@ -96,6 +98,10 @@ func ExtractMeta(data []byte) (*Meta, []byte, error) { case HeaderLayout: meta.Layout = strings.TrimSpace(value) + case HeaderSidebar: + meta.Layout = "article" + meta.Sidebar = strings.TrimSpace(value) + case HeaderAttachment: meta.Attachments[value] = value diff --git a/pkg/mark/stdlib/stdlib.go b/pkg/mark/stdlib/stdlib.go index 34172f0..a2182ff 100644 --- a/pkg/mark/stdlib/stdlib.go +++ b/pkg/mark/stdlib/stdlib.go @@ -95,7 +95,7 @@ func templates(api *confluence.API) (*template.Template, error) { /**/ ``, /**/ ``, /**/ `{{ .Body }}`, - /**/ ``, + /**/ `{{ .Sidebar }}`, /**/ ``, /**/ ``, `{{ else }}`,