add page for reading a single gemlog entry

This commit is contained in:
Travis Shears 2025-10-03 12:07:48 +02:00
parent 8414414f98
commit 02ed95a612
5 changed files with 78 additions and 17 deletions

View file

@ -0,0 +1,45 @@
package main
import (
"gemini_site/gemlog"
tea "github.com/charmbracelet/bubbletea"
)
type EntryPageModel struct {
entry gemlog.GemlogEntry
}
func initialEntryPageModel() EntryPageModel {
return EntryPageModel{}
}
func (m EntryPageModel) Update(msg tea.Msg, active bool, ctx *context) (EntryPageModel, tea.Cmd) {
switch msg := msg.(type) {
case gemlog.GemLogLoaded:
m.entry = msg.Log
case tea.KeyMsg:
if !active {
return m, nil
}
switch msg.String() {
case "left", "h":
cmd := func() tea.Msg {
return SwitchPages{Page: EntryList}
}
return m, cmd
}
}
return m, nil
}
func (m EntryPageModel) View() string {
s := m.entry.Slug
s += "\n\n"
s += m.entry.Gemtxt
s += "\n\n-------------------------\n"
s += "\n\nPress h or left arrow to go back"
return s
}