added /news-assets
This commit is contained in:
parent
5892c0af38
commit
4a13ba939e
1 changed files with 6 additions and 0 deletions
6
main.go
6
main.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
@ -106,6 +107,9 @@ func main() {
|
|||
// Serve static files (CSS, JS, etc.) from the /static directory
|
||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
|
||||
|
||||
// Serve files in the /data/news/ directory under /news-assets/
|
||||
http.Handle("/news-assets/", http.StripPrefix("/news-assets/", http.FileServer(http.Dir(dataDir+"/news/"))))
|
||||
|
||||
// Serve downloads.html at /downloads
|
||||
http.HandleFunc("/download", func(w http.ResponseWriter, r *http.Request) {
|
||||
renderTemplate(w, "download.html", nil)
|
||||
|
@ -236,6 +240,8 @@ func renderBlogEntry(w http.ResponseWriter, r *http.Request, blogName string, en
|
|||
|
||||
htmlContent := blackfriday.Run([]byte(entry.Content))
|
||||
|
||||
htmlContent = bytes.ReplaceAll(htmlContent, []byte("src=\"./"), []byte(fmt.Sprintf("src=\"/news-assets/%d/", entryNumber)))
|
||||
|
||||
pageData := PageData{
|
||||
Title: entry.Title,
|
||||
Date: entry.Date.Format("2006-01-02 15:04"),
|
||||
|
|
Loading…
Reference in a new issue