mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-13 20:14:56 +02:00
24 lines
786 B
JavaScript
24 lines
786 B
JavaScript
/**
|
|
* 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 { useMemo } from 'react';
|
|
import { useLocation } from '@docusaurus/router';
|
|
import { isSamePath } from './routesUtils';
|
|
function isVisible(item, pathname) {
|
|
if (item.unlisted && !isSamePath(item.permalink, pathname)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
/**
|
|
* Return the visible blog sidebar items to display.
|
|
* Unlisted items are filtered.
|
|
*/
|
|
export function useVisibleBlogSidebarItems(items) {
|
|
const { pathname } = useLocation();
|
|
return useMemo(() => items.filter((item) => isVisible(item, pathname)), [items, pathname]);
|
|
}
|
|
//# sourceMappingURL=blogUtils.js.map
|