Ghost/core/frontend/meta/author-url.js
Naz 6e075c78bf Moved URL service to backend
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events

- URL module is part of the backend heavily dependent on the model and fits perfectly here. Frontend should get the data it needs by passing a URL manager instance to it
2021-10-19 07:29:09 +13:00

21 lines
709 B
JavaScript

const urlService = require('../../server/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;