aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/data.go17
-rw-r--r--backend/home.go18
-rw-r--r--backend/router.go9
-rw-r--r--backend/templates/base.html38
-rw-r--r--backend/templates/home.html35
5 files changed, 111 insertions, 6 deletions
diff --git a/backend/data.go b/backend/data.go
new file mode 100644
index 0000000..adf5db3
--- /dev/null
+++ b/backend/data.go
@@ -0,0 +1,17 @@
+package backend
+
+type data struct {
+ title string
+ Article bool
+}
+
+func (d data) Title() string {
+ title := "anhgelus"
+ if d.Article {
+ title += " - log entry"
+ }
+ if len(d.title) != 0 {
+ title += " - " + d.title
+ }
+ return title
+}
diff --git a/backend/home.go b/backend/home.go
new file mode 100644
index 0000000..8577fec
--- /dev/null
+++ b/backend/home.go
@@ -0,0 +1,18 @@
+package backend
+
+import (
+ "html/template"
+ "net/http"
+
+ "github.com/go-chi/chi/v5"
+)
+
+func HandleHome(r *chi.Mux) {
+ r.Get("/", func(w http.ResponseWriter, r *http.Request) {
+ t := template.Must(template.ParseFS(templates, "templates/home.html", "templates/base.html"))
+ err := t.ExecuteTemplate(w, "base.html", &data{})
+ if err != nil {
+ panic(err)
+ }
+ })
+}
diff --git a/backend/router.go b/backend/router.go
index f5d0cc6..b1efea8 100644
--- a/backend/router.go
+++ b/backend/router.go
@@ -11,18 +11,15 @@ import (
"github.com/go-chi/chi/v5/middleware"
)
+//go:embed templates
+var templates embed.FS
+
func NewRouter() *chi.Mux {
r := chi.NewRouter()
r.Use(middleware.Timeout(30 * time.Second))
r.Use(middleware.Logger)
- r.Get("/", func(w http.ResponseWriter, r *http.Request) {
- _, err := w.Write([]byte("Hello World"))
- if err != nil {
- panic(err)
- }
- })
return r
}
diff --git a/backend/templates/base.html b/backend/templates/base.html
new file mode 100644
index 0000000..c994cac
--- /dev/null
+++ b/backend/templates/base.html
@@ -0,0 +1,38 @@
+<!doctype html>
+<html lang="fr">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>{{ .Title }}</title>
+ <link rel="stylesheet" href="/assets/styles.css">
+</head>
+<body>
+<header>
+ <img src="https://cdn.anhgelus.world/pfp.jpg" alt="pfp">
+ <nav>
+ <a href="">Home</a>
+ <a href="">Logs</a>
+ <a href="">Work</a>
+ <a href="">Philosophy</a>
+ <a href="">Lien 1</a>
+ <a href="">Lien 2</a>
+ <a href="">Lien 3</a>
+ <a href="">Lien 4</a>
+ </nav>
+</header>
+{{ if .Article }}
+<main>
+ {{ template "body" . }}
+</main>
+{{ else }}
+<article>
+ {{ template "body" . }}
+</article>
+{{ end }}
+<footer>
+ <p>&copy; 2025 - Anhgelus Morthuuzh</p>
+ <p>«&thinsp;Une citation&thinsp;»</p>
+ <p><a href="">Mentions légales</a></p>
+</footer>
+</body>
+</html> \ No newline at end of file
diff --git a/backend/templates/home.html b/backend/templates/home.html
new file mode 100644
index 0000000..ed450ac
--- /dev/null
+++ b/backend/templates/home.html
@@ -0,0 +1,35 @@
+{{define "body"}}
+<div class="introduction">
+ <h1>logs</h1>
+ <p>
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri tamen permagna accessio potest, si aliquod aeternum et infinitum impendere.
+ </p>
+</div>
+<article>
+ <article>
+ <h2><a href="log.html">Article title</a></h2>
+ <figure>
+ <a href="log.html"><img src="https://placehold.co/1920x1080" alt=""></a>
+ <figcaption>A placeholder.</figcaption>
+ </figure>
+ <p>
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri tamen permagna accessio potest, si aliquod aeternum et infinitum impendere malum nobis opinemur.
+ </p>
+ </article>
+ <article>
+ <h2><a href="log.html">Article title</a></h2>
+ <figure>
+ <a href="log.html"><img src="https://placehold.co/1920x1080" alt=""></a>
+ <figcaption>A placeholder.</figcaption>
+ </figure>
+ <p>
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri tamen permagna accessio potest, si aliquod aeternum et infinitum impendere malum nobis opinemur.
+ </p>
+ </article>
+ <div class="pagination">
+ <a href="">Précédent</a>
+ <p>01/15</p>
+ <a href="">Suivant</a>
+ </div>
+</article>
+{{end}} \ No newline at end of file