diff options
author | Sheogorath | 2019-10-10 14:55:34 +0200 |
---|---|---|
committer | GitHub | 2019-10-10 14:55:34 +0200 |
commit | cd34a8c70226a094b5698ae7ab8b3bcd5ce75b41 (patch) | |
tree | e7839d0751fea4f8e5deaed9560657c6ad97f946 /lib/models | |
parent | 3255649917569eb8f1bed02b1aed8045322736e4 (diff) | |
parent | f26f48793fdf5bb81f4bec5d7c50e5fe1ba978d6 (diff) |
Merge pull request #191 from ErikMichelson/feature/ogmetadata
Add customizable opengraph metadata for notes (see #40)
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/note.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/models/note.js b/lib/models/note.js index 3a8ccb67..141402ac 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -409,9 +409,18 @@ module.exports = function (sequelize, DataTypes) { if (meta.GA && (typeof meta.GA === 'string' || typeof meta.GA === 'number')) { _meta.GA = meta.GA } if (meta.disqus && (typeof meta.disqus === 'string' || typeof meta.disqus === 'number')) { _meta.disqus = meta.disqus } if (meta.slideOptions && (typeof meta.slideOptions === 'object')) { _meta.slideOptions = meta.slideOptions } + if (meta.opengraph && (typeof meta.opengraph === 'object')) { _meta.opengraph = meta.opengraph } } return _meta } + Note.parseOpengraph = function (meta, title) { + var _ogdata = {} + if (meta.opengraph) { _ogdata = meta.opengraph } + if (!(_ogdata.title && (typeof _ogdata.title === 'string' || typeof _ogdata.title === 'number'))) { _ogdata.title = title } + if (!(_ogdata.description && (typeof _ogdata.description === 'string' || typeof _ogdata.description === 'number'))) { _ogdata.description = meta.description || '' } + if (!(_ogdata.type && (typeof _ogdata.type === 'string'))) { _ogdata.type = 'website' } + return _ogdata + } Note.updateAuthorshipByOperation = function (operation, userId, authorships) { var index = 0 var timestamp = Date.now() |