Closed robertpostill closed 4 years ago
In case I don't otherwise say it. I love org2jekyll, thanks for doing this.
Hello,
thanks for the thorough report and the vote of confidence ;)
I changed recently the way org2jekyll publish things so it actually is able to
respect org-mode's options (toc, num, ...). For this, I added a hook to
'org-publish-after-publishing-hook, called org2jekyll-install-yaml-headers
.
That's the one in charge of writing the jekyll yaml headers (and drop temporary
file).
That's expectedly set if you activate org2jekyll-mode
M-x
org2jekyll-mode [1]
From your report, I gather it's not called thus why you don't see the yaml in your html (and also the draft file with the jekyll date).
So first question, did you activate M-x orgjekyll-mode? I guess not since I failed to mention it in the upgrade section [1]
Second, can you please check what's the content of
org-publish-after-publishing-hook
? M-: org-publish-after-publishing-hook
RET before and after activating org2jekyll (so you can check what I just
told you ;)
[1] I realize now that I did mention the hook thing in the upgrade section of the README. I failed to mention the mode needs to be activated now.
tl; dr I choose to install the hook through a mode so it could be activated and deactivated. To avoid any conflict, when org2jekyll-mode is deactivated, the hook is uninstalled as well, so as to avoid other org minor modes clash (who might org publish stuff as well).
Cheers,
To be clear, I intend to clarify the documentation about this later in the day (working right now ;) In the mean time, i'm still interested by your feedback.
Thanks in advance.
Cheers,
Thanks for the quick reply:smiley:. So I didn't have the minor mode enabled. I've adjusted my init.el to:
(require 'org)
(require 'org2jekyll)
(add-hook 'org-mode-hook 'turn-on-flyspell)
(add-hook 'org-mode-hook #'org2jekyll-mode)
As suggested I can see that org-publish-after-publishing-hook
now holds:
(org2jekyll-install-yaml-headers)
👍
This appears to have fixed the issue when publishing a single post. So org2jekyll-publish
works. However, I can still see the behaviour on org2jekyll-publish-posts
. If I run that the org files are created with dates prepended and the _posts
directory is untouched.
awesome for the first part.
So org2jekyll-publish works. However, I can still see the behaviour on org2jekyll-publish-posts. If I run that the org files are created with dates prepended and the _posts directory is untouched.
less so here...
Yeah, i guess that's the same issue alright...
Although, that one is more tricky, the org2jekyll mode needs to be activated on each buffer org2jekyll works on... I need to reflect more on this...
Because at this point (in the publishing-process), org-mode is in charge... ... (few hours passed in between ;) ...
Letting this rest a bit, I'm wondering if the following would work:
(defun org2jekyll--publish-post-org-file-with-metadata (org-metadata org-file)
"Publish as post with ORG-METADATA the ORG-FILE."
(let* ((blog-project (assoc-default "layout" org-metadata))
(file-date (-> (assoc-default "date" org-metadata) org2jekyll--convert-timestamp-to-yyyy-dd-mm))
(temp-file (org2jekyll--compute-ready-jekyll-file-name file-date org-file)))
(copy-file org-file temp-file 'overwrite 'keep-time 'preserve-ids 'preserve-perms)
(with-temp-file temp-file
(org2jekyll-mode)
(org-publish-file temp-file
(assoc blog-project org-publish-project-alist)))))
Can you please try the following?
M-: paste-the-snippet-above-here
RET
And then try and publish posts again?
I'm testing on my side as well.
I'm testing on my side as well.
From my tryouts, it seems to behave better that way but it's not entirely correct though. There remains dangling empty files YYYY-MM-DD-{post-filename}.org in the org2jekyll-source-directory...
That's annoying...
With the following, i'm happy:
(defun org2jekyll--publish-post-org-file-with-metadata (org-metadata org-file)
"Publish as post with ORG-METADATA the ORG-FILE."
(let* ((blog-project (assoc-default "layout" org-metadata))
(file-date (-> (assoc-default "date" org-metadata) org2jekyll--convert-timestamp-to-yyyy-dd-mm))
(temp-file (org2jekyll--compute-ready-jekyll-file-name file-date org-file))
(project (assoc blog-project org-publish-project-alist)))
(copy-file org-file temp-file 'overwrite 'keep-time 'preserve-ids 'preserve-perms)
(org2jekyll-message "File: %s\nlayout: %s" temp-file blog-project)
(org2jekyll-message "project: %s" project)
(with-temp-file temp-file
(org2jekyll-mode)
(org-publish-file temp-file project))
;; the hook should have kicked-in already
;; if it remains dangling temporary file, just delete it
(when (file-exists-p temp-file)
(delete-file temp-file))))
Now comes the refactoring phase ;)
And now, with this ^, I think the org2jekyll-mode is no longer required.
It can be nice to keep it for the bindings but it's no longer necessary for the publishing part.
Cheers,
I have cut a new release 0.2.6 with the fix.
Cheers,
Thanks so much. I've tested it and it's published articles so I think this is ready to close. Thanks again for your help and responsiveness.
Sure!
Thanks for raising the issue in the first place.
Now, I tend to publish one page/post at a time so I did not notice.
I have ceased the opportunity to improve on the reproducible steps (without having stuff conflated by my own configuration).
In the end, everybody wins so that's awesome ;)
Cheers,
bug?
Yes, I'm afraid so. It could also be me.
M-x org2jekyll-bug-report
Expected behaviour
When publishing a blog post I would expect that the blog post comes out an entire post. This has previously worked for me.
Actual behaviour
The HTML file appears in the _posts directory but is missing the front matter for Jekyll to process.
Also (I don't know if this is related) but org files appear with the date in them in my org dir. I will take that to a separate issue if that's not relevant to this issue. So here's the top of my org file:
Here's the top of the HTML file:
Steps to reproduce the behaviour
M-x org2jekyll-publish-posts
How can we try and reproduce? Relevant bit of my init.el