@@ -301,6 +301,19 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
301
301
}
302
302
}
303
303
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
+
313
+ } else {
314
+ c .DefaultOutputFormat = defaultOutputFormat .Name
315
+ }
316
+
304
317
disabledLangs := make (map [string ]bool )
305
318
for _ , lang := range c .DisableLanguages {
306
319
disabledLangs [lang ] = true
@@ -391,22 +404,23 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
391
404
}
392
405
393
406
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 ,
407
+ Timeout : timeout ,
408
+ BaseURL : baseURL ,
409
+ BaseURLLiveReload : baseURL ,
410
+ DisabledKinds : disabledKinds ,
411
+ DisabledLanguages : disabledLangs ,
412
+ IgnoredLogs : ignoredLogIDs ,
413
+ KindOutputFormats : kindOutputFormats ,
414
+ DefaultOutputFormat : defaultOutputFormat ,
415
+ ContentTypes : media .DefaultContentTypes .FromTypes (c .MediaTypes .Config ),
416
+ CreateTitle : helpers .GetTitleFunc (c .TitleCaseStyle ),
417
+ IsUglyURLSection : isUglyURL ,
418
+ IgnoreFile : ignoreFile ,
419
+ SegmentFilter : c .Segments .Config .Get (func (s string ) { logger .Warnf ("Render segment %q not found in configuration" , s ) }, c .RootConfig .RenderSegments ... ),
420
+ MainSections : c .MainSections ,
421
+ Clock : clock ,
422
+ HTTPCache : httpCache ,
423
+ transientErr : transientErr ,
410
424
}
411
425
412
426
for _ , s := range allDecoderSetups {
@@ -430,22 +444,23 @@ func (c *Config) IsLangDisabled(lang string) bool {
430
444
431
445
// ConfigCompiled holds values and functions that are derived from the config.
432
446
type 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
447
+ Timeout time.Duration
448
+ BaseURL urls.BaseURL
449
+ BaseURLLiveReload urls.BaseURL
450
+ ServerInterface string
451
+ KindOutputFormats map [string ]output.Formats
452
+ DefaultOutputFormat output.Format
453
+ ContentTypes media.ContentTypes
454
+ DisabledKinds map [string ]bool
455
+ DisabledLanguages map [string ]bool
456
+ IgnoredLogs map [string ]bool
457
+ CreateTitle func (s string ) string
458
+ IsUglyURLSection func (section string ) bool
459
+ IgnoreFile func (filename string ) bool
460
+ SegmentFilter segments.SegmentFilter
461
+ MainSections []string
462
+ Clock time.Time
463
+ HTTPCache httpcache.ConfigCompiled
449
464
450
465
// This is set to the last transient error found during config compilation.
451
466
// With themes/modules we compute the configuration in multiple passes, and
@@ -505,6 +520,10 @@ type RootConfig struct {
505
520
// Set this to true to put all languages below their language ID.
506
521
DefaultContentLanguageInSubdir bool
507
522
523
+ // The default output format to use for the site.
524
+ // If not set, we will use the first output format.
525
+ DefaultOutputFormat string
526
+
508
527
// Disable generation of redirect to the default language when DefaultContentLanguageInSubdir is enabled.
509
528
DisableDefaultLanguageRedirect bool
510
529
0 commit comments