Remove punctuation from blog IDs
This commit is contained in:
@@ -6,7 +6,9 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/CalebQ42/darkstorm-server/internal/backend"
|
||||
@@ -59,6 +61,11 @@ func (b *Blog) HTMX(blogApp *BlogApp, ctx context.Context) string {
|
||||
return out
|
||||
}
|
||||
|
||||
func (b Blog) IDFromTitle() string {
|
||||
id := strings.Join(regexp.MustCompile("([A-z]| |[0-9])*").FindAllString(b.Title, -1), "")
|
||||
return strings.ReplaceAll(id, " ", "-")
|
||||
}
|
||||
|
||||
func (b *BlogApp) ConvertBlog(blog *Blog) {
|
||||
if !blog.StaticPage {
|
||||
blog.HTMLBlog = b.conv.HTMLConvert(blog.RawBlog)
|
||||
|
||||
Reference in New Issue
Block a user