Skip to content

Commit

Permalink
Fix the case where date is not specified at all
Browse files Browse the repository at this point in the history
.. by wrapping (org-export-data (plist-get info :date) info) in org-string-nw-p

- Also fix the date specification in property drawer in small1.org
  example.
  • Loading branch information
kaushalmodi committed Jul 6, 2017
1 parent c52677b commit a1aed1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ This variable can be set to either `toml' or `yaml'."
(:hugo-date "HUGO_DATE" nil nil)
(:hugo-categories "HUGO_CATEGORIES" nil nil)
(:hugo-tags "HUGO_TAGS" nil nil) ;TODO: Also parse the Org tags as post tags
(:date "DATE" nil nil)
;; Optional front matter variables
(:hugo-aliases "HUGO_ALIASES" nil nil)
(:hugo-draft "HUGO_DRAFT" nil nil)
Expand Down Expand Up @@ -251,11 +252,11 @@ INFO is a plist used as a communication channel."
(let* ((fm-format (org-export-data (plist-get info :hugo-front-matter-format) info))
(hugo-date-fmt "%Y-%m-%dT%T%z")
(date (or ;; Get the date from the subtree property `EXPORT_DATE' if available
(org-export-data (plist-get info :date) info)
;; Else try to get it from the #+DATE keyword in the Org file
(org-string-nw-p (org-export-get-date info hugo-date-fmt))
;; Else finally set the date to the current date
(format-time-string hugo-date-fmt (current-time))))
(org-string-nw-p (org-export-data (plist-get info :date) info))
;; Else try to get it from the #+DATE keyword in the Org file
(org-string-nw-p (org-export-get-date info hugo-date-fmt))
;; Else finally set the date to the current date
(format-time-string hugo-date-fmt (current-time))))
(data `((title . ,(org-export-data (plist-get info :title) info))
(date . ,date)
(description . ,(org-export-data (plist-get info :hugo-description) info))
Expand Down
3 changes: 1 addition & 2 deletions tests/org/small1/small1.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

* Post 1
:PROPERTIES:
:DATE: June 11, 2000
:EXPORT_DATE: June 11, 2000
:END:
Something
* Post 2
:PROPERTIES:
:CUSTOM_ID: testxyz
:FOO: There
:END:
Something Else

0 comments on commit a1aed1c

Please sign in to comment.