Skip to content

Commit

Permalink
export to different project directory
Browse files Browse the repository at this point in the history
i added two defcustoms - one for setting the md-project directory, and one to
prompt for a dir.

with the first you can always export to a the same location, with the second
you can choose each time where you export to.
  • Loading branch information
mousebot committed May 12, 2022
1 parent 26edb3f commit c4f7fcb
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions ox-jekyll-md.el
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ makes:
:group 'org-export-jekyll
:type 'boolean)

(defcustom org-export-jekyll-md-project-directory default-directory
"Directory to save exported articles to.
\nDefaults to `default-directory' (i.e. current directory). See
`org-export-jekyll-md-use-prompt-for-directory' if you
want to choose a directory on saving."
:group 'org-export-jekyll
:type 'string)

(defcustom org-export-jekyll-md-prompt-for-directory nil
"Non-nil means prompt for a directory to save in.
\nStart at `org-export-jekyll-md-project-directory'. Nil means
use `org-export-jekyll-md-project-directory' with no prompt."
:group 'org-export-jekyll
:type 'boolean)

;;; Define Back-End

(org-export-define-derived-backend 'jekyll 'md
Expand Down Expand Up @@ -303,10 +318,20 @@ holding export options."

;;;###autoload
(defun org-jekyll-md-export-to-md (&optional async subtreep visible-only)
"Export current buffer to a Markdown file adding some YAML front matter."
"Export current buffer to a Markdown file adding some YAML front matter.
\nThe file is saved to `org-export-jekyll-md-project-directory'.
If `org-export-jekyll-md-prompt-for-directory' is non-nil, prompt
for a directory to save to."
(interactive)
(let ((outfile (concat (org-jekyll-md-filename-date)
(org-export-output-file-name ".md" subtreep))))
(let* ((pub-dir (if org-export-jekyll-md-prompt-for-directory
(read-directory-name "Save to: "
org-export-jekyll-md-project-directory
nil
t)
org-export-jekyll-md-project-directory))
(outfile (concat pub-dir
(org-jekyll-md-filename-date)
(org-export-output-file-name ".md" subtreep))))
(org-export-to-file 'jekyll outfile async subtreep visible-only)))

;;;###autoload
Expand Down

0 comments on commit c4f7fcb

Please sign in to comment.