@prezly/theme-kit-core
Version:
Data layer and utility library for developing Prezly themes with JavaScript
28 lines (27 loc) • 811 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.generateUrl = generateUrl;
exports.getDataRequestUrl = getDataRequestUrl;
var _themeKitIntl = require("@prezly/theme-kit-intl");
var _constants = require("./constants.cjs");
function generateUrl(newsroom, locale, options) {
var {
email,
action = 'subscribe'
} = options || {};
var {
slug
} = _themeKitIntl.Locale.from(locale);
var url = new URL("/".concat(slug, "/newsroom/").concat(newsroom.uuid, "/").concat(action), _constants.PRIVACY_PORTAL_URL);
if (email) {
url.searchParams.append('email', email);
}
return url.toString();
}
function getDataRequestUrl(newsroom, locale) {
return newsroom.custom_data_request_link || generateUrl(newsroom, locale, {
action: 'data-request'
});
}