Fix
This commit is contained in:
parent
014fb3a35c
commit
4a0b59c45b
1 changed files with 5 additions and 3 deletions
|
@ -3,14 +3,15 @@ package pages
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
|
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/yuin/goldmark"
|
"github.com/yuin/goldmark"
|
||||||
highlighting "github.com/yuin/goldmark-highlighting/v2"
|
highlighting "github.com/yuin/goldmark-highlighting/v2"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
contentfs "goth.stack/content"
|
||||||
"goth.stack/lib"
|
"goth.stack/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,10 +25,11 @@ type PostProps struct {
|
||||||
func Post(c echo.Context) error {
|
func Post(c echo.Context) error {
|
||||||
postName := c.Param("post")
|
postName := c.Param("post")
|
||||||
|
|
||||||
filePath := "content/" + postName + ".md"
|
filePath := postName + ".md"
|
||||||
|
|
||||||
md, err := os.ReadFile(filePath)
|
md, err := fs.ReadFile(contentfs.FS, filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println(err.Error())
|
||||||
http.Error(c.Response().Writer, "This post does not exist!", http.StatusNotFound)
|
http.Error(c.Response().Writer, "This post does not exist!", http.StatusNotFound)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue