Ghost/core/frontend/meta/author-url.js
Hannah Wolfe af4bfb8862
Changed meta filenames to correct casing
- purely for cleanliness!
- we use kebabcase by default
- tests should be kebab-case-file_spec.js (one day we want this to be .test.js)
2021-07-01 12:30:25 +01:00

21 lines
699 B
JavaScript

const urlService = require('../services/url');
const getContextObject = require('./context-object.js');
function getAuthorUrl(data, absolute) {
let context = data.context ? data.context[0] : null;
const contextObject = getContextObject(data, context);
if (data.author) {
return urlService.getUrlByResourceId(data.author.id, {absolute: absolute, secure: data.author.secure, withSubdirectory: true});
}
if (contextObject && contextObject.primary_author) {
return urlService.getUrlByResourceId(contextObject.primary_author.id, {absolute: absolute, secure: contextObject.secure, withSubdirectory: true});
}
return null;
}
module.exports = getAuthorUrl;