Skip to content

Commit 0db7031

Browse files
committed
feat(config): add image backend as a property option
1 parent b821567 commit 0db7031

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

internal/config/style.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ const (
2323
)
2424

2525
type Properties struct {
26-
Title string `yaml:"title"`
27-
Style StyleConfig `yaml:"style"`
28-
Transition transitions.Transition `yaml:"transition"`
29-
Notes string `yaml:"notes"`
26+
Title string `yaml:"title"`
27+
Style StyleConfig `yaml:"style"`
28+
Transition transitions.Transition `yaml:"transition"`
29+
Notes string `yaml:"notes"`
30+
ImageBackend string `yaml:"image_backend"`
3031
}
3132

3233
type SlideStyle struct {
@@ -214,11 +215,12 @@ func getLayoutPosition(p string) (lipgloss.Position, error) {
214215

215216
func (p *Properties) UnmarshalYAML(bytes []byte) error {
216217
aux := struct {
217-
Title string `yaml:"title"`
218-
Style StyleConfig `yaml:"style"`
219-
Transition string `yaml:"transition"`
220-
Preset string `yaml:"preset"`
221-
Notes string `yaml:"notes"`
218+
Title string `yaml:"title"`
219+
Style StyleConfig `yaml:"style"`
220+
Transition string `yaml:"transition"`
221+
Preset string `yaml:"preset"`
222+
Notes string `yaml:"notes"`
223+
ImageBackend string `yaml:"image_backend"`
222224
}{}
223225

224226
if err := yaml.Unmarshal(bytes, &aux); err != nil {
@@ -227,6 +229,7 @@ func (p *Properties) UnmarshalYAML(bytes []byte) error {
227229

228230
p.Title = aux.Title
229231
p.Notes = aux.Notes
232+
p.ImageBackend = aux.ImageBackend
230233

231234
if aux.Preset != "" {
232235
preset, ok := GlobalConfig.Presets[aux.Preset]
@@ -256,6 +259,9 @@ func (p *Properties) UnmarshalYAML(bytes []byte) error {
256259
if p.Transition == nil {
257260
p.Transition = GlobalConfig.Global.Transition
258261
}
262+
if p.ImageBackend == "" {
263+
p.ImageBackend = "chafa"
264+
}
259265

260266
return nil
261267
}

internal/tui/slide.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewSlide(data string, props config.Properties) (*Slide, error) {
3232
themeName = props.Style.Theme.Name
3333
}
3434

35-
r, err := markdown.NewRenderer(themeName)
35+
r, err := markdown.NewRenderer(themeName, markdown.WithImageBackend(props.ImageBackend))
3636
if err != nil {
3737
return nil, err
3838

0 commit comments

Comments
 (0)