tannerdolby / eleventy-plugin-metagen

Eleventy shortcode that generates document metadata
https://www.npmjs.com/package/eleventy-plugin-metagen
MIT License
41 stars 3 forks source link

Add support for user-defined custom tags #20

Closed tannerdolby closed 2 years ago

tannerdolby commented 2 years ago

Allow user-defined tags, that is an ability to specify any custom field that isn't mentioned in the README.md or docs e.g. data.my_custom_field:

{% metagen 
   my_custom_field = ["meta", {name: "foo", content: "bar"}]
%}

would generate:

<meta name="foo" content="bar">
tannerdolby commented 2 years ago

Support added and custom tags can be added/generated using the custom argument.

Parameter: custom - an array of "element" arrays. custom type: Array<Array> element array type: Array[3] or Array[4] details:

Example usage:

{% metagen 
   title="some title",
   custom=[["meta", "", {name: "myCustomTag", content: "foo" }]]
%}

=>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>some title</title>
<meta name="title" content="some title">
<meta property="og:type" content="website">
<meta property="og:locale" content="en_US">
<meta property="og:title" content="some title">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@undefined">
<meta name="twitter:title" content="some title">
<meta name="myCustomTag" content="foo">