/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/_dogfooding/migrateStorageNamespace.ts
31 строка
1 KB
Sébastien Lorber
feat(core): site storage config options (experimental) (#10121)
10 май 2024, 15:41
Не верифицирован
10 май 2024, 15:41
620e463
Код
Авторство
О чём код?
/** * 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); }