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 document.getElementById('post-content').innerHTML =\n marked.parse( markdown );\n\n </script>")
|
|
|
|
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 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-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 = BasicPageBlock().Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
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
|
|
|
|
}
|
2025-02-15 10:22:02 +03:00
|
|
|
var templ_7745c5c3_Var15 = []any{styling.FileHeader(), styling.HighlightText()}
|
|
|
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var15...)
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<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-15 10:22:02 +03:00
|
|
|
var templ_7745c5c3_Var16 string
|
|
|
|
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var15).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-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
|
|
|
|
}
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\">")
|
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_Var17 string
|
|
|
|
templ_7745c5c3_Var17, 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: 59, Col: 16}
|
|
|
|
}
|
|
|
|
_, 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, 14, "</h1>")
|
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_Var18 = []any{styling.BlogContainer()}
|
|
|
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var18...)
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<div class=\"")
|
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_Var19 string
|
|
|
|
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var18).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-15 10:22:02 +03:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\">")
|
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_Var20 = []any{}
|
|
|
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var20...)
|
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-15 10:22:02 +03:00
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<div class=\"")
|
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_Var21 string
|
|
|
|
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var20).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_Var21))
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
}
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "\" 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-15 10:22:02 +03:00
|
|
|
templ_7745c5c3_Var22 := templ.GetChildren(ctx)
|
|
|
|
if templ_7745c5c3_Var22 == nil {
|
|
|
|
templ_7745c5c3_Var22 = templ.NopComponent
|
2025-01-28 18:43:37 +03:00
|
|
|
}
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
|
|
|
templ_7745c5c3_Err = BasicPageBlock().Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
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-15 10:22:02 +03:00
|
|
|
var templ_7745c5c3_Var23 = []any{styling.Textcontainer(), styling.BlogContainer()}
|
|
|
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var23...)
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<div class=\"")
|
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_Var24 string
|
|
|
|
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var23).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-15 10:22:02 +03:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\"><h1 style=\"font-family: Disket-Mono;\">")
|
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_Var25 = []any{styling.Header()}
|
|
|
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var25...)
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<a class=\"")
|
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_Var26 string
|
|
|
|
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var25).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-15 10:22:02 +03:00
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\" href=\"")
|
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_Var27 templ.SafeURL = templ.URL(fmt.Sprintf("/post/%v", posts[i].Id))
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var27)))
|
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
|
|
|
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-15 10:22:02 +03:00
|
|
|
var templ_7745c5c3_Var28 string
|
|
|
|
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(posts[i].Header)
|
2025-01-28 18:43:37 +03:00
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-02-15 10:22:02 +03:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 79, Col: 36}
|
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_Var28))
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</a></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-15 10:22:02 +03:00
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<p id=\"post-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_Var29 string
|
|
|
|
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(shortStr, " "))
|
2025-01-28 18:43:37 +03:00
|
|
|
if templ_7745c5c3_Err != nil {
|
2025-02-15 10:22:02 +03:00
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/templates/blog.templ`, Line: 92, Col: 62}
|
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_Var29))
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "... </p>")
|
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_Var30 = []any{styling.HighlightText()}
|
|
|
|
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-15 10:22:02 +03:00
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<a class=\"")
|
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_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-15 10:22:02 +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-15 10:22:02 +03:00
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\" href=\"")
|
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_Var32 templ.SafeURL = templ.URL(fmt.Sprintf("/post/%v", posts[i].Id))
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var32)))
|
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
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "\">Читать полностью...</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
|