@sanity/desk-tool
Version:
Tool for managing all sorts of content in a structured manner
26 lines (24 loc) • 974 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPreviewUrl = getPreviewUrl;
var _resolveProductionUrl = _interopRequireDefault(require("part:@sanity/transitional/production-preview/resolve-production-url?"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// @todo: remove the following line when part imports has been removed from this file
///<reference types="@sanity/types/parts" />
function getPreviewUrl(historyController, value) {
var revTime = historyController.revTime;
var rev = revTime ? revTime.id : null;
if (!value || !_resolveProductionUrl.default) {
return null;
}
try {
return (0, _resolveProductionUrl.default)(value, rev);
} catch (error) {
error.message = "An error was thrown while trying to get production preview url: ".concat(error.message);
// eslint-disable-next-line no-console
console.error(error);
return null;
}
}