new: Added about me page and fixed some bugs

This commit is contained in:
2024-12-19 11:23:19 +08:00
parent 0d419dabd1
commit cbd6d07d52
15 changed files with 267 additions and 40 deletions

View File

@@ -156,3 +156,35 @@ func (ma *MApp) parseMarkdowns() error {
model.SortPostsByDate(ma.Posts)
return nil
}
func (ma *MApp) parseSingleMarkdown(src, dst string) error {
// read markdown file
_mdFile, err := os.Open(src)
if err != nil {
return err
}
defer _mdFile.Close()
_mdByte, err := io.ReadAll(_mdFile)
if err != nil {
return err
}
// convert into html format and save to html file
_htmlFile, err := os.Create(dst)
if err != nil {
return err
}
defer _htmlFile.Close()
// set options to lute
ma.lute.SetToC(true)
_htmlByte := ma.lute.Markdown(src, _mdByte)
_, err = _htmlFile.Write(_htmlByte)
if err != nil {
return err
}
return nil
}