45 lines
801 B
Go
45 lines
801 B
Go
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
|
|
}
|