ukarim / ngx_markdown_filter_module

Markdown-to-html nginx module
MIT License
18 stars 3 forks source link

Feature to populate title and other head/meta data from a config file #3

Open drmuey opened 1 year ago

drmuey commented 1 year ago

It currently sets the title via JS looking through {{content}}. That is helpful but its not great for SEO as some indexers would miss the title that way and they can’t do anything unique to the content.

However, if this supported metadata for the content somehow like front matter in foo.md (or external .foo.json but front matter feels more ideal).

Example

Markdown file:

---
title: title here
meta:
  robots:
    - index
    - nofollow
  description: "description here"
---

# My page

Lorum Ipsom …

markdown_template

<meta charset="utf-8">
<meta name="robots" content="{{meta.robots}}">
<meta name="description" content="{{meta.description}}">

<title>{{title}}</title>

rendered as

<meta charset="UTF-8">
<meta name="robots" content="index, nofollow">
<meta name="description" content="description here">

<title>title here</title>

Support for doing 1 or more link/script/etc tags could be a round 2 thing if it too crazy but Ienvision like:

TAG_NAME::
  - attr1: val1
    attr2: val2
  - attr1: val3
    attr2: val4
  - attr3: val5
    attr4: val6
    .content : "I am content"

Rendering as:

I am content

Perhaps the loop syntax can be borrowed from a common existing template format.

drmuey commented 1 year ago

If it consumed a global config it could merge the front matter on top, that way each markdown would only need to specify what differs from the default.