Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read jekyll style Front Matter for titles and other metadata #50

Open
jessebmiller opened this issue Feb 24, 2018 · 2 comments
Open

Read jekyll style Front Matter for titles and other metadata #50

jessebmiller opened this issue Feb 24, 2018 · 2 comments

Comments

@jessebmiller
Copy link

It would be sweet to use deft for writing markdown files for static sites.

The titles and other metadata for these files however are in Front Matter (YAML) rather than on the first line.

---
layout: post
title: Write Your Blog Using Deft!!!
---

Start of the post
...
@bcclaywell
Copy link

Seconding this. I couldn't work around this by providing a new deft-parse-title-function as that function is only passed the first line, and I couldn't get it to work adding advice to deft-parse-title. This feature would be great!

@bcclaywell
Copy link

For anyone from the future, here's what more or less works for me:

(defun my-strip-front-matter (contents)
  (replace-regexp-in-string "^---\\(?:\n.*\\)*---.*$" "" contents))

(defun my-deft-parse-title-wrapper (f file contents)
  (let ((new-contents (my-strip-front-matter contents)))
    (funcall f file new-contents)))

(defun my-deft-parse-summary-wrapper (f contents title)
  (let ((new-contents (my-strip-front-matter contents)))
    (funcall f new-contents title)))

(advice-add 'deft-parse-title :around 'my-deft-parse-title-wrapper)
(advice-add 'deft-parse-summary :around 'my-deft-parse-summary-wrapper)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants