import { DocsLogo } from '@expo/styleguide'; import { PlanEnterpriseIcon, BookOpen02Icon, GraduationHat02Icon, Home02Icon, } from '@expo/styleguide-icons'; import { Command } from 'cmdk'; import type { AlgoliaItemType } from '../types'; import { getContentHighlightHTML, getHighlightHTML, isReferencePath, isEASPath, openLink, isHomePath, isLearnPath, } from '../utils'; import { FootnoteSection } from './FootnoteSection'; import { FootnoteArrowIcon } from './icons'; import { contentStyle, footnoteStyle, itemIconWrapperStyle, itemStyle } from './styles'; import versions from '~/public/static/constants/versions.json'; import { CALLOUT, FOOTNOTE } from '~/ui/components/Text'; const { LATEST_VERSION } = versions; type Props = { item: AlgoliaItemType; onSelect?: () => void; }; const isDev = process.env.NODE_ENV === 'development'; const ItemIcon = ({ url }: { url: string }) => { if (isReferencePath(url)) { return ; } else if (isEASPath(url)) { return ; } else if (isHomePath(url)) { return ; } else if (isLearnPath(url)) { return ; } return ; }; const getFootnotePrefix = (url: string) => { if (isReferencePath(url)) { return 'Reference'; } else if (isEASPath(url)) { return 'Expo Application Services'; } else if (isHomePath(url)) { return 'Home'; } else if (isLearnPath(url)) { return 'Learn'; } else { return 'Guides'; } }; const ItemFootnotePrefix = ({ url, isNested = false }: { url: string; isNested?: boolean }) => { return isNested ? ( <> {getFootnotePrefix(url)} > ) : ( {getFootnotePrefix(url)} ); }; const transformUrl = (url: string) => { if (url.includes(LATEST_VERSION)) { url = url.replace(LATEST_VERSION, 'latest'); } if (isDev) { url = url.replace('https://docs.expo.dev/', 'http://localhost:3002/'); } return url; }; export const ExpoDocsItem = ({ item, onSelect }: Props) => { const { lvl0, lvl2, lvl3, lvl4, lvl6 } = item.hierarchy; return ( { openLink(transformUrl(item.url)); onSelect && onSelect(); }}> {lvl6 && ( <> > )} {!lvl6 && lvl4 && ( <> > )} {!lvl6 && !lvl4 && lvl3 && ( <> > )} {!lvl6 && !lvl4 && !lvl3 && lvl2 && ( <> > )} {!lvl6 && !lvl4 && !lvl3 && !lvl2 && lvl0 && ( <> > )} ); };