commit 84954bcd2e666a66a8ab006b3311573b65575a17 from: ale date: Sun Aug 30 01:07:52 2026 UTC Resolve a relative theme: path against the deck's directory A 'theme: theme.json' in the frontmatter now loads from the presentation file's folder, like bibliography and images already do, instead of the process's working directory -- so 'slides sub/dir/deck.md' finds sub/dir/theme.json. Builtin keywords (ascii/light/dark/notty), URLs and absolute paths are unchanged. commit - 218876a9c1d446e99f769452e8d7de0a88ca359f commit + 84954bcd2e666a66a8ab006b3311573b65575a17 blob - 2ee9d2b5ee2c3bfcbc86cc955df2f4c4e32814a9 blob + a809a9a71d0d14c3a9b74133377f9bfe93159819 --- internal/model/model.go +++ internal/model/model.go @@ -394,6 +394,21 @@ func centerLines(s string, width int) string { return strings.Join(lines, "\n") } +// resolveThemeRef makes a relative `theme:` path in the frontmatter +// resolve against the presentation file's directory (as bibliography and +// images already do), not the process's working directory. Builtin +// keywords, URLs and absolute paths pass through untouched. +func (m *Model) resolveThemeRef(ref string) string { + switch ref { + case "", "ascii", "light", "dark", "notty": + return ref + } + if strings.HasPrefix(ref, "http") || filepath.IsAbs(ref) { + return ref + } + return filepath.Join(m.imageBaseDir(), ref) +} + func fileWatchCmd() tea.Cmd { return tea.Every(time.Second, func(t time.Time) tea.Msg { return fileWatchMsg{} @@ -432,7 +447,7 @@ func (m *Model) Load() error { m.Date = metaData.Date m.Paging = metaData.Paging if m.Theme == nil { - m.Theme = styles.SelectTheme(metaData.Theme) + m.Theme = styles.SelectTheme(m.resolveThemeRef(metaData.Theme)) // Computed here, once, before the tea.Program takes over the // terminal: HasDarkBackground does its own OSC 11 query, which // would race with Bubble Tea's input reader if called later from