xcatliu / pagic

A static site generator powered by Deno + React
https://pagic.org
MIT License
1.64k stars 104 forks source link

Feature Request: Support yaml front matter #1

Closed tracker1 closed 7 years ago

tracker1 commented 7 years ago

Would be really nice if this supported yaml front matter[1], when present passed as first parameter instead of title... This would allow for more dynamic options as well as some additional configurability (like not processing an item when the "published" date is in the future.

index.md

---
title: My Title
published: 2017-02-28
--- 
# {title}

My Content

_layout.js

module.exports = function ({ frontMatter, content, relativeToRoot }) {
  return `
    <!doctype html>
    <html>
      <head>
        <title>${frontMatter.title}</title>
        <link rel="stylesheet" href="${relativeToRoot}/css/site.css" />
      </head>
      <body>
        ${content}
        <footer>
          published: ${frontMatter.published}
        </footer>
      </body>
    </html>
  `
};

[1] http://assemble.io/docs/YAML-front-matter.html

xcatliu commented 7 years ago

Good idea, I'll considering add this feature, thanks!

xcatliu commented 7 years ago

@tracker1 I've added front-matter feature, but I didn't implement the replacement of front-matter variables in markdown files

# {title}

Both Jekyll and Hexo doesn't support this.

You can add

<h1>${frontMatter.title}</h1>

in the _layout.js instead.

tracker1 commented 7 years ago

Awesome... should probably update the documentation, really happy to see this, thanks.

xcatliu commented 7 years ago

@tracker1 Updated README.md

wu529778790 commented 7 years ago

没有汉语版本,差评

xcatliu commented 7 years ago

@wu529778790 即使看不懂英文,看 README 里面的代码应该基本上就知道怎么用了。 等我有空了再加上中文说明。