Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(sidebar): Add sidebar support #89

Merged
merged 1 commit into from
Jun 30, 2021
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<!-- Sidebar: <h2>Test</h2> -->
```

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.:

Expand Down
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/mark/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
HeaderAttachment = `Attachment`
HeaderLabel = `Label`
HeaderInclude = `Include`
HeaderSidebar = `Sidebar`
)

type Meta struct {
Expand All @@ -27,6 +28,7 @@ type Meta struct {
Type string
Title string
Layout string
Sidebar string
Attachments map[string]string
Labels []string
}
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pkg/mark/stdlib/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func templates(api *confluence.API) (*template.Template, error) {
/**/ `<ac:layout>`,
/**/ `<ac:layout-section ac:type="two_right_sidebar">`,
/**/ `<ac:layout-cell>{{ .Body }}</ac:layout-cell>`,
/**/ `<ac:layout-cell></ac:layout-cell>`,
/**/ `<ac:layout-cell>{{ .Sidebar }}</ac:layout-cell>`,
/**/ `</ac:layout-section>`,
/**/ `</ac:layout>`,
`{{ else }}`,
Expand Down