@@ -301,6 +301,18 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
301301 }
302302 }
303303
304+ defaultOutputFormat := outputFormats [0 ]
305+ c .DefaultOutputFormat = strings .ToLower (c .DefaultOutputFormat )
306+ if c .DefaultOutputFormat != "" {
307+ f , found := outputFormats .GetByName (c .DefaultOutputFormat )
308+ if ! found {
309+ return fmt .Errorf ("unknown default output format %q" , c .DefaultOutputFormat )
310+ }
311+ defaultOutputFormat = f
312+ } else {
313+ c .DefaultOutputFormat = defaultOutputFormat .Name
314+ }
315+
304316 disabledLangs := make (map [string ]bool )
305317 for _ , lang := range c .DisableLanguages {
306318 disabledLangs [lang ] = true
@@ -391,22 +403,23 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
391403 }
392404
393405 c .C = & ConfigCompiled {
394- Timeout : timeout ,
395- BaseURL : baseURL ,
396- BaseURLLiveReload : baseURL ,
397- DisabledKinds : disabledKinds ,
398- DisabledLanguages : disabledLangs ,
399- IgnoredLogs : ignoredLogIDs ,
400- KindOutputFormats : kindOutputFormats ,
401- ContentTypes : media .DefaultContentTypes .FromTypes (c .MediaTypes .Config ),
402- CreateTitle : helpers .GetTitleFunc (c .TitleCaseStyle ),
403- IsUglyURLSection : isUglyURL ,
404- IgnoreFile : ignoreFile ,
405- SegmentFilter : c .Segments .Config .Get (func (s string ) { logger .Warnf ("Render segment %q not found in configuration" , s ) }, c .RootConfig .RenderSegments ... ),
406- MainSections : c .MainSections ,
407- Clock : clock ,
408- HTTPCache : httpCache ,
409- transientErr : transientErr ,
406+ Timeout : timeout ,
407+ BaseURL : baseURL ,
408+ BaseURLLiveReload : baseURL ,
409+ DisabledKinds : disabledKinds ,
410+ DisabledLanguages : disabledLangs ,
411+ IgnoredLogs : ignoredLogIDs ,
412+ KindOutputFormats : kindOutputFormats ,
413+ DefaultOutputFormat : defaultOutputFormat ,
414+ ContentTypes : media .DefaultContentTypes .FromTypes (c .MediaTypes .Config ),
415+ CreateTitle : helpers .GetTitleFunc (c .TitleCaseStyle ),
416+ IsUglyURLSection : isUglyURL ,
417+ IgnoreFile : ignoreFile ,
418+ SegmentFilter : c .Segments .Config .Get (func (s string ) { logger .Warnf ("Render segment %q not found in configuration" , s ) }, c .RootConfig .RenderSegments ... ),
419+ MainSections : c .MainSections ,
420+ Clock : clock ,
421+ HTTPCache : httpCache ,
422+ transientErr : transientErr ,
410423 }
411424
412425 for _ , s := range allDecoderSetups {
@@ -430,22 +443,23 @@ func (c *Config) IsLangDisabled(lang string) bool {
430443
431444// ConfigCompiled holds values and functions that are derived from the config.
432445type ConfigCompiled struct {
433- Timeout time.Duration
434- BaseURL urls.BaseURL
435- BaseURLLiveReload urls.BaseURL
436- ServerInterface string
437- KindOutputFormats map [string ]output.Formats
438- ContentTypes media.ContentTypes
439- DisabledKinds map [string ]bool
440- DisabledLanguages map [string ]bool
441- IgnoredLogs map [string ]bool
442- CreateTitle func (s string ) string
443- IsUglyURLSection func (section string ) bool
444- IgnoreFile func (filename string ) bool
445- SegmentFilter segments.SegmentFilter
446- MainSections []string
447- Clock time.Time
448- HTTPCache httpcache.ConfigCompiled
446+ Timeout time.Duration
447+ BaseURL urls.BaseURL
448+ BaseURLLiveReload urls.BaseURL
449+ ServerInterface string
450+ KindOutputFormats map [string ]output.Formats
451+ DefaultOutputFormat output.Format
452+ ContentTypes media.ContentTypes
453+ DisabledKinds map [string ]bool
454+ DisabledLanguages map [string ]bool
455+ IgnoredLogs map [string ]bool
456+ CreateTitle func (s string ) string
457+ IsUglyURLSection func (section string ) bool
458+ IgnoreFile func (filename string ) bool
459+ SegmentFilter segments.SegmentFilter
460+ MainSections []string
461+ Clock time.Time
462+ HTTPCache httpcache.ConfigCompiled
449463
450464 // This is set to the last transient error found during config compilation.
451465 // With themes/modules we compute the configuration in multiple passes, and
@@ -505,6 +519,10 @@ type RootConfig struct {
505519 // Set this to true to put all languages below their language ID.
506520 DefaultContentLanguageInSubdir bool
507521
522+ // The default output format to use for the site.
523+ // If not set, we will use the first output format.
524+ DefaultOutputFormat string
525+
508526 // Disable generation of redirect to the default language when DefaultContentLanguageInSubdir is enabled.
509527 DisableDefaultLanguageRedirect bool
510528
0 commit comments