import Head from 'next/head' ; import { useRouter } from 'next/router' ; import { useJupyterBookData } from '@/context/jupyterBook' ; import { createUrl , isExternalUrl } from '@/utils/url' ; param path returns function createNapariOrgUrl ( path ) { const { pathname } = createUrl ( path ) ; const baseUrl = process . env . PREVIEW_BASE_URL || '' ; return `${ baseUrl }${ pathname }` ; } /**
 * Component for adding meta tags to add support for rich previews on Twitter
 * and OpenGraph websites.
 */ export function MetaPreviews ( ) { const router = useRouter ( ) ; const { pageTitle , previewImage , previewDescription } = useJupyterBookData ( ) ; const previewUrl = router . asPath && createNapariOrgUrl ( router . asPath ) ; let previewImageLink = previewImage ; if ( ! isExternalUrl ( previewImage ) ) { previewImageLink = createNapariOrgUrl ( previewImage ) ; } return ( < Head > { } < meta name = "twitter:card" content = { previewImage ? 'summary_large_image' : 'summary' } / > < meta name = "twitter:site" content = "@napari_imaging" / > < meta name = "twitter:title" content = { pageTitle } / > < meta name = "twitter:description" content = { previewDescription } / > < meta name = "twitter:creator" content = "@napari_imaging" / > { previewImage && < meta name = "twitter:image" content = { previewImageLink } / > } { } < meta property = "og:title" content = { pageTitle } / > < meta property = "og:type" content = "article" / > < meta property = "og:url" content = { previewUrl } / > < meta property = "og:description" content = { previewDescription } / > < meta property = "og:site_name" content = "napari.org" / > { previewImage && < meta name = "og:image" content = { previewImageLink } / > } < /Head>); }