Skip to content

Commit f3d34dd

Browse files
committed
fix: allow atom layout module names
String values for layout module names are required to be supported in the front matter, but it feels odd to require that they be strings in config. This enables the specification of layout modules as atoms and fixes a bug in PageExtension which required a layout value in the front matter at all times.
1 parent 9585d16 commit f3d34dd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: lib/tableau/extensions/page_extension.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ defmodule Tableau.PageExtension do
7373
optional(:enabled, true) => bool(),
7474
optional(:dir, "_pages") => str(),
7575
optional(:permalink) => str(),
76-
optional(:layout) => str()
76+
optional(:layout) => oneof([str(), atom()])
7777
}),
7878
input
7979
)
@@ -113,7 +113,7 @@ defmodule Tableau.PageExtension do
113113
|> Map.put(:__tableau_page_extension__, true)
114114
|> Map.put(:body, body)
115115
|> Map.put(:file, filename)
116-
|> Map.put(:layout, Module.concat([front_matter.layout || pages_config.layout]))
116+
|> Map.put(:layout, Module.concat([front_matter[:layout] || pages_config.layout]))
117117
|> Common.build_permalink(pages_config)
118118
end
119119
end

Diff for: lib/tableau/extensions/post_extension.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ defmodule Tableau.PostExtension do
8181
optional(:dir, "_posts") => str(),
8282
optional(:future, false) => bool(),
8383
optional(:permalink) => str(),
84-
optional(:layout) => str()
84+
optional(:layout) => oneof([atom(), str()])
8585
}),
8686
config
8787
)

0 commit comments

Comments
 (0)