mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-10 14:52:29 +02:00
31 lines
1 KiB
TypeScript
31 lines
1 KiB
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
import SiteStorage from '@generated/site-storage';
|
|
|
|
// The purpose is to test a migration script for storage namespacing
|
|
// See also: https://github.com/facebook/docusaurus/pull/10121
|
|
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
const migrateStorageKey = (key: string) => {
|
|
const value = localStorage.getItem(key);
|
|
if (value !== null && SiteStorage.namespace) {
|
|
const newKey = `${key}${SiteStorage.namespace}`;
|
|
console.log(`Updating storage key [${key} => ${newKey}], value=${value}`);
|
|
localStorage.setItem(newKey, value);
|
|
localStorage.removeItem(key);
|
|
}
|
|
};
|
|
|
|
const storageKeys = [
|
|
'theme',
|
|
'docusaurus.announcement.id',
|
|
'docusaurus.announcement.dismiss',
|
|
'docs-preferred-version-default',
|
|
];
|
|
storageKeys.forEach(migrateStorageKey);
|
|
}
|