Make the setting-the-date example conditional
This makes the example a bit more realistic/valuable by checking if the metadata value "date" is already present, before changing the value.
This commit is contained in:
parent
93e3d463fd
commit
214f2f08e4
1 changed files with 5 additions and 3 deletions
|
@ -362,12 +362,14 @@ end
|
||||||
## Setting the date in the metadata
|
## Setting the date in the metadata
|
||||||
|
|
||||||
This filter sets the date in the document's metadata to the
|
This filter sets the date in the document's metadata to the
|
||||||
current date:
|
current date, if a date isn't already set:
|
||||||
|
|
||||||
``` lua
|
``` lua
|
||||||
function Meta(m)
|
function Meta(m)
|
||||||
m.date = os.date("%B %e, %Y")
|
if m.date == nil then
|
||||||
return m
|
m.date = os.date("%B %e, %Y")
|
||||||
|
return m
|
||||||
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue