Skip to content

Commit 2c9f73c

Browse files
committed
feature: pass-through yaml metadata image to html meta tag
Signed-off-by: schokotets <moritzleni@gmail.com>
1 parent 7b14845 commit 2c9f73c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/note/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ async function showPublishNote (req, res) {
121121
const data = {
122122
title: title,
123123
description: meta.description || (markdown ? Note.generateDescription(markdown) : null),
124+
image: meta.image,
124125
viewcount: note.viewcount,
125126
createtime: createTime,
126127
updatetime: updateTime,

public/docs/yaml-metadata.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ This option will set the note description.
4040
description: meta description
4141
```
4242
43+
image
44+
---
45+
This option will set the html meta tag 'image'.
46+
47+
> default: not set
48+
49+
**Example**
50+
```yml
51+
image: https://raw.githubusercontent.com/hackmdio/codimd/develop/public/screenshot.png
52+
```
53+
4354
tags
4455
---
4556
This option will set the tags which prior than content tags.

public/views/pretty.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<% if(typeof robots !== 'undefined' && robots) { %>
1212
<meta name="robots" content="<%= robots %>">
1313
<% } %>
14+
<% if(typeof image !== 'undefined' && image) { %>
15+
<meta name="image" content="<%= image %>">
16+
<% } %>
1417
<% if(typeof description !== 'undefined' && description) { %>
1518
<meta name="description" content="<%= description %>">
1619
<% } %>

0 commit comments

Comments
 (0)