summaryrefslogtreecommitdiff
path: root/internal/frontmatter/parser.go
diff refs
from:
to:
flip
diff options
context:
space:
mode:
Diffstat (limited to 'internal/frontmatter/parser.go')
-rw-r--r--internal/frontmatter/parser.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/internal/frontmatter/parser.go b/internal/frontmatter/parser.go
deleted file mode 100644
index 83312dc..0000000
--- a/internal/frontmatter/parser.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package frontmatter
-
-import (
- "fmt"
- "regexp"
- "time"
-
- "gopkg.in/yaml.v3"
-)
-
-type Metadata struct {
- Title string `yaml:"title"`
- ShortDescription string `yaml:"shortDescription"`
- ActionDate string `yaml:"actionDate"`
- PublishedTime time.Time `yaml:"publishedTime"`
- Thumbnail string `yaml:"thumbnail"`
- Tags []string `yaml:"tags"`
- Geolocation string `yaml:"geolocation"`
- Medley string `yaml:"medley"`
- MedleyPart int `yaml:"medleyPart"`
-}
-
-func ParseFrontmatter(content []byte) (metadata *Metadata, markdown []byte, err error) {
- frontmatterRegex := regexp.MustCompile(`^---\s*\r?\n([\s\S]*?)\r?\n---\s*\r?\n([\s\S]*)$`)
- matches := frontmatterRegex.FindSubmatch(content)
-
- if len(matches) != 3 {
- return nil, content, nil
- }
-
- yamlContent := matches[1]
- markdownContent := matches[2]
-
- metadata = &Metadata{}
- if err := yaml.Unmarshal([]byte(yamlContent), &metadata); err != nil {
- return nil, nil, fmt.Errorf("failed to parse YAML frontmatter: %w", err)
- }
-
- return metadata, markdownContent, nil
-}