import { LinkGetProps } from '@reach/router' ; import { MenuNode , TocItem , Edge } from 'interfaces/nodes' ; import { Color , themeProps , Space } from '../components/foundations/Theme' ; export const getColor = ( colorKey ) => themeProps . colors [ colorKey ] ; export const getSpacing = ( spaceKey ) => themeProps . space [ spaceKey ] ; export const getPageById = ( sectionList , templateFile ? ) => { if ( ! templateFile ) { return undefined ; } const sectionItems = sectionList . map ( ( { node } ) => node . items ) ; const flattenedSectionItems = ( [ ] as TocItem [ ] ) . concat ( ... sectionItems ) ; return flattenedSectionItems . find ( item => item . id === templateFile ) ; } ; /** Workaround for activeClassName: https://github.com/gatsbyjs/gatsby/issues/7737 */ export const isActive = ( { isPartiallyCurrent } ) => { return isPartiallyCurrent ? { className : 'active' } : { } ; } ;