new: Complete modules related to home page, archive page and article page

This commit is contained in:
2024-12-16 14:13:58 +08:00
parent 04267841f0
commit 65e5e9eafc
49 changed files with 1547 additions and 1 deletions

9
utils/markdown.go Normal file
View 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)
}