mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-01 19:27:48 +02:00
33 lines
976 B
TypeScript
33 lines
976 B
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 {createStorageSlot} from '../storageUtils';
|
|
import type {DocsVersionPersistence} from '../useThemeConfig';
|
|
|
|
const storageKey = (pluginId: string) => `docs-preferred-version-${pluginId}`;
|
|
|
|
const DocsPreferredVersionStorage = {
|
|
save: (
|
|
pluginId: string,
|
|
persistence: DocsVersionPersistence,
|
|
versionName: string,
|
|
): void => {
|
|
createStorageSlot(storageKey(pluginId), {persistence}).set(versionName);
|
|
},
|
|
|
|
read: (
|
|
pluginId: string,
|
|
persistence: DocsVersionPersistence,
|
|
): string | null =>
|
|
createStorageSlot(storageKey(pluginId), {persistence}).get(),
|
|
|
|
clear: (pluginId: string, persistence: DocsVersionPersistence): void => {
|
|
createStorageSlot(storageKey(pluginId), {persistence}).del();
|
|
},
|
|
};
|
|
|
|
export default DocsPreferredVersionStorage;
|