@kontent-ai/smart-link
Version:
Kontent.ai Smart Link SDK allowing to automatically inject [smart links](https://docs.kontent.ai/tutorials/develop-apps/build-strong-foundation/set-up-editing-from-preview#a-using-smart-links) to Kontent.ai according to manually specified [HTML data attri
34 lines • 1.06 kB
JavaScript
import { logWarn } from '../lib/Logger';
const LocalStorageNotAvailable = 'Local storage is not available or access to local storage is denied for the current document. It may affect the proper work of the SDK.';
export function createStorage(key) {
return {
get() {
try {
const value = window.localStorage.getItem(key);
return value ? JSON.parse(value) : null;
}
catch {
logWarn(LocalStorageNotAvailable);
return null;
}
},
set(data) {
try {
const json = JSON.stringify(data);
window.localStorage.setItem(key, json);
}
catch {
logWarn(LocalStorageNotAvailable);
}
},
remove() {
try {
window.localStorage.removeItem(key);
}
catch {
logWarn(LocalStorageNotAvailable);
}
},
};
}
//# sourceMappingURL=storage.js.map