mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-03 05:42:35 +00:00
Add Content-Appearance header
Allows switching between the "full-width" and "fixed" page layouts. The "fixed" layout renders the page in a narrow column. (Confluence default) If not configured, it defaults to "full-width".
This commit is contained in:
@@ -11,28 +11,35 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
HeaderParent = `Parent`
|
||||
HeaderSpace = `Space`
|
||||
HeaderType = `Type`
|
||||
HeaderTitle = `Title`
|
||||
HeaderLayout = `Layout`
|
||||
HeaderAttachment = `Attachment`
|
||||
HeaderLabel = `Label`
|
||||
HeaderInclude = `Include`
|
||||
HeaderSidebar = `Sidebar`
|
||||
HeaderParent = `Parent`
|
||||
HeaderSpace = `Space`
|
||||
HeaderType = `Type`
|
||||
HeaderTitle = `Title`
|
||||
HeaderLayout = `Layout`
|
||||
HeaderAttachment = `Attachment`
|
||||
HeaderLabel = `Label`
|
||||
HeaderInclude = `Include`
|
||||
HeaderSidebar = `Sidebar`
|
||||
ContentAppearance = `Content-Appearance`
|
||||
)
|
||||
|
||||
type Meta struct {
|
||||
Parents []string
|
||||
Space string
|
||||
Type string
|
||||
Title string
|
||||
Layout string
|
||||
Sidebar string
|
||||
Attachments []string
|
||||
Labels []string
|
||||
Parents []string
|
||||
Space string
|
||||
Type string
|
||||
Title string
|
||||
Layout string
|
||||
Sidebar string
|
||||
Attachments []string
|
||||
Labels []string
|
||||
ContentAppearance string
|
||||
}
|
||||
|
||||
const (
|
||||
FullWidthContentAppearance = "full-width"
|
||||
FixedContentAppearance = "fixed"
|
||||
)
|
||||
|
||||
var (
|
||||
reHeaderPatternV1 = regexp.MustCompile(`\[\]:\s*#\s*\(([^:]+):\s*(.*)\)`)
|
||||
reHeaderPatternV2 = regexp.MustCompile(`<!--\s*([^:]+):\s*(.*)\s*-->`)
|
||||
@@ -78,7 +85,8 @@ func ExtractMeta(data []byte) (*Meta, []byte, error) {
|
||||
|
||||
if meta == nil {
|
||||
meta = &Meta{}
|
||||
meta.Type = "page" //Default if not specified
|
||||
meta.Type = "page" // Default if not specified
|
||||
meta.ContentAppearance = FullWidthContentAppearance // Default to full-width for backwards compatibility
|
||||
}
|
||||
|
||||
//nolint:staticcheck
|
||||
@@ -119,6 +127,13 @@ func ExtractMeta(data []byte) (*Meta, []byte, error) {
|
||||
// Includes are parsed by a different func
|
||||
continue
|
||||
|
||||
case ContentAppearance:
|
||||
if strings.TrimSpace(value) == FixedContentAppearance {
|
||||
meta.ContentAppearance = FixedContentAppearance
|
||||
} else {
|
||||
meta.ContentAppearance = FullWidthContentAppearance
|
||||
}
|
||||
|
||||
default:
|
||||
log.Errorf(
|
||||
nil,
|
||||
|
||||
Reference in New Issue
Block a user