fix: metadata no longer rendered as part of page content

This commit is contained in:
Daniel Fichtinger 2025-03-24 00:44:36 -04:00
parent 116fb6a883
commit fdb8753538
2 changed files with 11 additions and 3 deletions

View file

@ -28,7 +28,7 @@ type PageData struct {
Type string
}
type Metadata map[string]interface{}
type Metadata map[string]any
func processWithYaml(f []byte) (Metadata, []byte, error) {
// 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 {
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 {
return err
}

View file

@ -93,7 +93,6 @@ func ReadLineRange(filename string, start int, end int) ([]byte, error) {
scanner := bufio.NewScanner(file)
i := 0
for scanner.Scan() {
i++
if i >= start && (i <= end || end == -1) {
buffer.Write(scanner.Bytes())
buffer.WriteByte('\n')
@ -101,6 +100,7 @@ func ReadLineRange(filename string, start int, end int) ([]byte, error) {
if i > end && end != -1 {
break
}
i++
}
if err := scanner.Err(); err != nil {