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

Function getTitle

packages/dev/s2-docs/src/Layout.tsx:96–114  ·  view source on GitHub ↗
(currentPage: Page)

Source from the content-addressed store, hash-verified

94});
95
96const getTitle = (currentPage: Page): string => {
97 const explicitTitle = (currentPage as any).pageTitle || currentPage.exports?.pageTitle;
98 if (
99 explicitTitle &&
100 explicitTitle !== currentPage.tableOfContents?.[0]?.title &&
101 explicitTitle !== currentPage.name
102 ) {
103 return explicitTitle as string;
104 }
105
106 let library = getLibraryLabel(getLibraryFromPage(currentPage));
107 const pageTitle = currentPage.tableOfContents?.[0]?.title ?? currentPage.name;
108
109 if (currentPage.name === 'index.html' || currentPage.name.endsWith('/index.html')) {
110 return library || 'React Spectrum';
111 }
112
113 return library ? `${pageTitle} | ${library}` : pageTitle;
114};
115
116const getOgImageUrl = (currentPage: Page): string => {
117 let currentURL = new URL(currentPage.url);

Callers 1

LayoutFunction · 0.70

Calls 2

getLibraryLabelFunction · 0.90
getLibraryFromPageFunction · 0.90

Tested by

no test coverage detected