651 lines
28 KiB
Go
Raw Normal View History

2025-01-28 18:43:37 +03:00
// Code generated by templ - DO NOT EDIT.
2025-02-03 19:14:40 +03:00
// templ: version: v0.3.833
2025-01-28 18:43:37 +03:00
/*
Template that grew in complexity recently. It's was first template that supports JS.
1. Template contains local templ blocks their names starting with lowercase to make it DRY
2. JS script is seperated and should be called *after* page construction.
3. Templ ShowBlogPage contains some math to dynamicly reduce post size
TODO - make it more DRY and modular in general
*/
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import "github.com/dixxe/personal-website/web/static/styling"
import "github.com/dixxe/personal-website/iternal/pkg/repositories"
import "fmt"
import "strings"
import "math"
var markedHandle = templ.NewOnceHandle()
func runMarked(markdown string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templ.JSONScript("md", markdown).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<script src=\"https://cdn.jsdelivr.net/npm/marked/marked.min.js\"></script> <script type=\"text/javascript\">\n\n const markdown = JSON.parse(document.getElementById('md').textContent);\n marked.use({\n pedantic: false,\n breaks: true,\n gfm: true,\n });\n document.getElementById('post-content').innerHTML =\n marked.parse( markdown );\n\n </script>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = markedHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func blogHeader() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
if templ_7745c5c3_Var3 == nil {
templ_7745c5c3_Var3 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-02-15 10:22:02 +03:00
var templ_7745c5c3_Var4 = []any{styling.BlogHeading()}
2025-01-28 18:43:37 +03:00
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var4...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-15 10:22:02 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var4).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-15 10:22:02 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-15 10:22:02 +03:00
var templ_7745c5c3_Var6 = []any{styling.BubbleContainer(), styling.BlogHeadingLeft()}
2025-01-28 18:43:37 +03:00
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var6...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-15 10:22:02 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var6).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-15 10:22:02 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 = []any{styling.Header()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var8...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<p class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var8).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\" style=\"font-family: Disket-Mono;\">Блог нуля</p></div><div></div><div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 = []any{styling.BubbleContainer(), styling.BlogHeadingRight()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var10...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var10).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 = []any{styling.Header()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var12...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<p class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var12).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\">Вернуться <a href=\"/\">Домой</a></p></div></div>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func postBlockSeo(post repositories.Post) templ.Component {
2025-01-28 18:43:37 +03:00
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
2025-02-15 10:22:02 +03:00
templ_7745c5c3_Var14 := templ.GetChildren(ctx)
if templ_7745c5c3_Var14 == nil {
templ_7745c5c3_Var14 = templ.NopComponent
2025-01-28 18:43:37 +03:00
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<!doctype HTML><html style=\"background-color: #272727; \"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"icon\" type=\"image/png\" href=\"/static/icon.png\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = LoadFontsBlock().Render(ctx, templ_7745c5c3_Buffer)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
// It's probably awfull practice, but here I calculate
// post size and make it smaller.. In frontend! Magic!
// Doing it again because seo!!
postWords := strings.Fields(post.Content)
postCap := int(math.Sqrt(float64(len(postWords)) * 5))
if postCap > 150 {
postCap = 150
}
shortStr := postWords[:postCap]
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<meta name=\"description\" content=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(shortStr, " "))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 80, Col: 69}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\"><meta http-equiv=\"Content-Language\" content=\"ru\"><meta name=\"robots\" content=\"index, follow\"><meta property=\"og:title\" content=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-15 10:22:02 +03:00
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(post.Header)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
2025-02-16 12:22:51 +03:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 84, Col: 54}
2025-01-28 18:43:37 +03:00
}
2025-02-15 10:22:02 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\"><meta property=\"og:description\" content=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(shortStr, " "))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 85, Col: 76}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\"><meta property=\"og:url\" content=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("https://dixxe.top/post/%v", post.Id))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 86, Col: 90}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\"><title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(post.Header)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 88, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</title></head></html>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func blogBlockSeo() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Var20 := templ.GetChildren(ctx)
if templ_7745c5c3_Var20 == nil {
templ_7745c5c3_Var20 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<!doctype HTML><html style=\"background-color: #272727; \"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"icon\" type=\"image/png\" href=\"/static/icon.png\">")
2025-02-15 10:22:02 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
2025-02-15 10:22:02 +03:00
}
templ_7745c5c3_Err = LoadFontsBlock().Render(ctx, templ_7745c5c3_Buffer)
2025-02-15 10:22:02 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<meta name=\"description\" content=\"Блог nullmax17\"><meta http-equiv=\"Content-Language\" content=\"ru\"><meta name=\"robots\" content=\"index, follow\"><meta property=\"og:title\" content=\"Персональный блог nullmax17\"><meta property=\"og:description\" content=\"Блог какого-то программиста в котором он делится своими знаниями.\"><meta property=\"og:url\" content=\"https://dixxe.top/blog\"><title>nullmax17's blog</title></head></html>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func ShowPost(post repositories.Post) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Var21 := templ.GetChildren(ctx)
if templ_7745c5c3_Var21 == nil {
templ_7745c5c3_Var21 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = postBlockSeo(post).Render(ctx, templ_7745c5c3_Buffer)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = blogHeader().Render(ctx, templ_7745c5c3_Buffer)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<div style=\"margin: 2%;\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
2025-01-28 18:43:37 +03:00
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var22 = []any{styling.FileHeader(), styling.HighlightText()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var22...)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<h1 style=\"font-family: Disket-Mono\" class=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var22).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
2025-02-15 10:22:02 +03:00
return templ_7745c5c3_Err
2025-01-28 18:43:37 +03:00
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var24 string
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(post.Header)
2025-02-15 10:22:02 +03:00
if templ_7745c5c3_Err != nil {
2025-02-16 12:22:51 +03:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 123, Col: 20}
2025-02-15 10:22:02 +03:00
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
2025-02-15 10:22:02 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</h1></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var25 = []any{styling.BlogContainer()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var25...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<div class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var26 string
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var25).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var27 = []any{}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var27...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<div class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var28 string
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var27).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\" id=\"post-content\"></div></div>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = runMarked(post.Content).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func ShowBlogPage(posts []repositories.Post) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Var29 := templ.GetChildren(ctx)
if templ_7745c5c3_Var29 == nil {
templ_7745c5c3_Var29 = templ.NopComponent
2025-01-28 18:43:37 +03:00
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = blogBlockSeo().Render(ctx, templ_7745c5c3_Buffer)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = blogHeader().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for i := len(posts) - 1; i >= 0; i-- {
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var30 = []any{styling.Textcontainer(), styling.BlogContainer()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var30...)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<div class=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var31 string
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var30).String())
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var32 = []any{styling.Header()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var32...)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "<h1 class=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var33 string
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var32).String())
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "\" style=\"font-family: Disket-Mono;\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var34 string
templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(posts[i].Header)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
2025-02-16 12:22:51 +03:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 144, Col: 32}
2025-01-28 18:43:37 +03:00
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</h1>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
// It's probably awfull practice, but here I calculate
// post size and make it smaller.. In frontend! Magic!
postWords := strings.Fields(posts[i].Content)
postCap := int(math.Sqrt(float64(len(postWords)) * 5))
shortStr := postWords[:postCap]
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<p id=\"post-content\">")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var35 string
templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(shortStr, " "))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
2025-02-16 12:22:51 +03:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 156, Col: 62}
2025-01-28 18:43:37 +03:00
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "... </p>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var36 = []any{styling.HighlightText()}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var36...)
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<a class=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var37 string
templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var36).String())
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 1, Col: 0}
}
2025-02-16 12:22:51 +03:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "\" href=\"")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
var templ_7745c5c3_Var38 templ.SafeURL = templ.URL(fmt.Sprintf("/post/%v", posts[i].Id))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var38)))
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-02-16 12:22:51 +03:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "\">Читать полностью...</a></div>")
2025-01-28 18:43:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = UsefulLinks().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate