try page embed
This commit is contained in:
parent
be89141c06
commit
513d0e57ce
10 changed files with 29 additions and 26 deletions
|
|
@ -1,11 +1,11 @@
|
|||
package microblog
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gemini_site/internal/pocketbase"
|
||||
"log/slog"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -216,6 +216,9 @@ func drawPost(builder *strings.Builder, p post) {
|
|||
// p.Timestamp.Format("2006-01-02 15:04")))
|
||||
}
|
||||
|
||||
//go:embed microblog.gmi
|
||||
var pageContnet string
|
||||
|
||||
// serveBlogIndex serves the main blog page with recent posts
|
||||
func (mb *MicroBlog) serveIndex(w gemini.ResponseWriter, req *gemini.Request, pageNum int) {
|
||||
w.WriteStatusMsg(gemini.StatusSuccess, "text/gemini")
|
||||
|
|
@ -225,12 +228,7 @@ func (mb *MicroBlog) serveIndex(w gemini.ResponseWriter, req *gemini.Request, pa
|
|||
// content.WriteString("Here are my microblog posts from various plantforms\n")
|
||||
// Read and include the contents of ../../pages/microblog.gmi
|
||||
if pageNum == 1 {
|
||||
page, err := os.ReadFile("./pages/microblog.gmi")
|
||||
if err != nil {
|
||||
slog.Error("Problem reading microblog page", "error", err)
|
||||
return
|
||||
}
|
||||
content.Write(page)
|
||||
content.Write([]byte(pageContnet))
|
||||
content.WriteString("\n")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue