Skip to content

Commit

Permalink
Add hugo directory vars and export to hugo section dir
Browse files Browse the repository at this point in the history
After this change =org-hugo-export-to-md= will always export to a
hugo directory. There's no option to disable this yet, though there
probably should be.
  • Loading branch information
titaniumbones authored and kaushalmodi committed Jun 29, 2017
1 parent 4cf6b59 commit 04aa36c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions ox-hugo.el
Expand Up @@ -29,7 +29,6 @@

(require 'ox-blackfriday)


;;; User-Configurable Variables

(defgroup org-export-hugo nil
Expand All @@ -45,7 +44,6 @@ This variable can be set to either `toml' or `yaml'."
:group 'org-export-hugo
:type 'string)


;;; Define Back-End

(org-export-define-derived-backend 'hugo 'blackfriday
Expand All @@ -69,7 +67,10 @@ This variable can be set to either `toml' or `yaml'."
(:hugo-categories "HUGO_CATEGORIES" nil nil)
(:hugo-description "HUGO_DESCRIPTION" nil nil)
(:hugo-slug "HUGO_SLUG" nil nil)
(:hugo-url "HUGO_URL" nil nil)))
(:hugo-url "HUGO_URL" nil nil)
(:hugo-export-dir "HUGO_EXPORT_DIR" nil nil)
(:hugo-section "HUGO_SECTION" "posts" nil)
(:hugo-static-images "HUGO_STATIC_IMAGES" "image" nil)))


;;; Transcode Functions
Expand Down Expand Up @@ -254,7 +255,20 @@ contents of hidden elements.
Return output file's name."
(interactive)
(let ((outfile (org-export-output-file-name ".md" subtreep)))

;; steals some plist reading code
;; from =org-export-as=
;; allows us to extract destination file info from
;; export-options-alist
(let* ((info (org-combine-plists
(org-export--get-export-attributes
'hugo subtreep visible-only)
(org-export--get-buffer-attributes)
(org-export-get-environment 'hugo subtreep)))
(pub-dir (concat (file-name-as-directory (plist-get info :hugo-export-dir) )
(file-name-as-directory "content")
(file-name-as-directory (plist-get info :hugo-section))))
(outfile (org-export-output-file-name ".md" subtreep pub-dir)))
(org-export-to-file 'hugo outfile async subtreep visible-only)))

;;;###autoload
Expand Down

0 comments on commit 04aa36c

Please sign in to comment.