MCPcopy Create free account
hub / github.com/adobe/react-spectrum / Layout

Function Layout

packages/dev/s2-docs/src/Layout.tsx:217–387  ·  view source on GitHub ↗
(props: PageProps & {children: ReactElement<any>})

Source from the content-addressed store, hash-verified

215}
216
217export 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({

Callers

nothing calls this directly

Calls 10

getCurrentPageFunction · 0.90
getLibraryLabelFunction · 0.90
getLibraryFromPageFunction · 0.90
getOgImageUrlFunction · 0.85
getFaviconUrlFunction · 0.85
componentsFunction · 0.85
sliceMethod · 0.80
getTitleFunction · 0.70
getDescriptionFunction · 0.70
filterMethod · 0.65

Tested by

no test coverage detected