mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
new: Complete modules related to home page, archive page and article page
This commit is contained in:
9
utils/markdown.go
Normal file
9
utils/markdown.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package utils
|
||||
|
||||
import "regexp"
|
||||
|
||||
// ExtractFrontMatter Extract markdown header information and return clean text
|
||||
func ExtractFrontMatter(data []byte) ([]byte, []byte) {
|
||||
re := regexp.MustCompile(`(?s)^\s*---\s*\n.*?\n\s*---\s*\n`)
|
||||
return re.FindSubmatch(data)[0], re.ReplaceAll(data, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user