feat: initial commit
This commit is contained in:
41
internal/http/handler/webui/quiz/component/quiz_page.templ
Normal file
41
internal/http/handler/webui/quiz/component/quiz_page.templ
Normal file
@ -0,0 +1,41 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"forge.cadoles.com/wpetit/kouiz/internal/http/form"
|
||||
common "forge.cadoles.com/wpetit/kouiz/internal/http/handler/webui/common/component"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/yuin/goldmark"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
type QuizPageVModel struct {
|
||||
}
|
||||
|
||||
func NewQuizForm() *form.Form {
|
||||
return form.New(
|
||||
form.NewField(
|
||||
"project",
|
||||
form.Attrs{},
|
||||
form.NonEmpty("Ce champ ne doit pas être vide."),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
templ QuizPage(vmodel QuizPageVModel) {
|
||||
@common.AppPage(common.WithPageOptions(
|
||||
common.WithTitle("Quiz"),
|
||||
)) {
|
||||
}
|
||||
}
|
||||
|
||||
func markdownToHTML(ctx context.Context, text string) string {
|
||||
var buff bytes.Buffer
|
||||
if err := goldmark.Convert([]byte(text), &buff); err != nil {
|
||||
slog.ErrorContext(ctx, "could not convert markdown to html", slog.Any("error", errors.WithStack(err)))
|
||||
return ""
|
||||
}
|
||||
|
||||
return buff.String()
|
||||
}
|
Reference in New Issue
Block a user