42 lines
865 B
Plaintext
42 lines
865 B
Plaintext
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()
|
|
}
|