fix: metadata no longer rendered as part of page content
This commit is contained in:
parent
116fb6a883
commit
fdb8753538
2 changed files with 11 additions and 3 deletions
|
@ -28,7 +28,7 @@ type PageData struct {
|
||||||
Type string
|
Type string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Metadata map[string]interface{}
|
type Metadata map[string]any
|
||||||
|
|
||||||
func processWithYaml(f []byte) (Metadata, []byte, error) {
|
func processWithYaml(f []byte) (Metadata, []byte, error) {
|
||||||
// Check if the file has valid metadata
|
// Check if the file has valid metadata
|
||||||
|
@ -155,7 +155,15 @@ func BuildFile(f *File, settings *Settings) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildHtmlFile(l int, in string, out string, pd *PageData, settings *Settings) error {
|
func BuildHtmlFile(l int, in string, out string, pd *PageData, settings *Settings) error {
|
||||||
md, err := util.ReadLineRange(in, l, -1)
|
// WARN: ReadLineRange is fine, but l is the len of the frontmatter
|
||||||
|
// NOT including the delimiters!
|
||||||
|
start := l
|
||||||
|
// if the frontmatter exists (len > 0), then we need to
|
||||||
|
// account for two lines of delimiter!
|
||||||
|
if l != 0 {
|
||||||
|
start += 2
|
||||||
|
}
|
||||||
|
md, err := util.ReadLineRange(in, start, -1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,6 @@ func ReadLineRange(filename string, start int, end int) ([]byte, error) {
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
i := 0
|
i := 0
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
i++
|
|
||||||
if i >= start && (i <= end || end == -1) {
|
if i >= start && (i <= end || end == -1) {
|
||||||
buffer.Write(scanner.Bytes())
|
buffer.Write(scanner.Bytes())
|
||||||
buffer.WriteByte('\n')
|
buffer.WriteByte('\n')
|
||||||
|
@ -101,6 +100,7 @@ func ReadLineRange(filename string, start int, end int) ([]byte, error) {
|
||||||
if i > end && end != -1 {
|
if i > end && end != -1 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue