(props: PageProps & {children: ReactElement<any>})
| 215 | } |
| 216 | |
| 217 | export async function Layout(props: PageProps & {children: ReactElement<any>}) { |
| 218 | let {children} = props; |
| 219 | let pages = await getPages(); |
| 220 | let currentPage = getCurrentPage(props.currentPage); |
| 221 | let isToastPage = currentPage.name === 's2/Toast'; |
| 222 | let isSubpage = currentPage.exports?.isSubpage; |
| 223 | let section = currentPage.exports?.section; |
| 224 | let isLongForm = isSubpage && section === 'Blog'; |
| 225 | let hasToC = |
| 226 | (!currentPage.exports?.hideNav || section === 'Blog' || section === 'Releases') && |
| 227 | currentPage.tableOfContents?.[0]?.children && |
| 228 | currentPage.tableOfContents?.[0]?.children?.length > 0; |
| 229 | let isWide = !hasToC && !isLongForm && section !== 'Blog' && section !== 'Releases'; |
| 230 | let library = getLibraryLabel(getLibraryFromPage(currentPage)); |
| 231 | let keywords = [ |
| 232 | ...new Set((currentPage.exports?.keywords ?? []).concat([library]).filter(k => !!k)) |
| 233 | ]; |
| 234 | let ogImage = getOgImageUrl(currentPage); |
| 235 | let title = getTitle(currentPage); |
| 236 | let description = getDescription(currentPage); |
| 237 | let parentUrl = new URL('./', currentPage.url); |
| 238 | let parentIndex = parentUrl.href; |
| 239 | let parentPageUrl = parentUrl.href.slice(0, -1); |
| 240 | let parentPage = pages.find(p => p.url === parentIndex || p.url === parentPageUrl); |
| 241 | let isPostList = currentPage.exports?.isPostList; |
| 242 | let Content = isPostList ? PostListContainer : Article; |
| 243 | return ( |
| 244 | <Router currentPage={currentPage} pages={pages}> |
| 245 | <Provider |
| 246 | elementType="html" |
| 247 | locale="en" |
| 248 | background="layer-1" |
| 249 | styles={style({scrollPaddingTop: {default: 64, lg: 0}})}> |
| 250 | <head> |
| 251 | <meta charSet="utf-8" /> |
| 252 | <title>{title}</title> |
| 253 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 254 | <link |
| 255 | rel="alternate" |
| 256 | type="text/markdown" |
| 257 | title="LLM-friendly version" |
| 258 | href={currentPage.url.replace(/\.html$/, '.md')} |
| 259 | /> |
| 260 | <link rel="icon" href={getFaviconUrl(currentPage)} /> |
| 261 | <meta name="description" content={description} /> |
| 262 | {keywords.length > 0 ? <meta name="keywords" content={keywords.join(',')} /> : null} |
| 263 | <meta name="twitter:card" content="summary_large_image" /> |
| 264 | <meta name="twitter:image" content={ogImage} /> |
| 265 | <meta property="og:title" content={title} /> |
| 266 | <meta property="og:type" content="website" /> |
| 267 | <meta property="og:url" content={currentPage.url} /> |
| 268 | <meta property="og:image" content={ogImage} /> |
| 269 | <meta property="og:description" content={description} /> |
| 270 | <meta property="og:locale" content="en_US" /> |
| 271 | <link rel="canonical" href={currentPage.url} /> |
| 272 | </head> |
| 273 | <body |
| 274 | className={style({ |
nothing calls this directly
no test coverage detected