MCPcopy Create free account
hub / github.com/TanStack/devtools / SerpPreviewSection

Function SerpPreviewSection

packages/devtools/src/tabs/seo-tab/serp-preview.tsx:200–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198}
199
200export function SerpPreviewSection() {
201 const [serp, setSerp] = createSignal<SerpData>(getSerpFromHead())
202
203 createHeadChanges(() => {
204 setSerp(getSerpFromHead())
205 })
206
207 const serpPreviewState = createMemo(() => {
208 const data = serp()
209 const titleText = data.title || 'No title'
210 const descText = data.description || 'No meta description.'
211
212 const displayTitle = truncateToChars(titleText, TITLE_MAX_CHARS)
213 const displayDescription = truncateToChars(descText, DESCRIPTION_MAX_CHARS)
214
215 return {
216 displayTitle,
217 displayDescription,
218 overflow: {
219 titleOverflow: titleText.length > TITLE_MAX_CHARS,
220 descriptionOverflow: descText.length > DESCRIPTION_MAX_CHARS,
221 descriptionOverflowMobile:
222 descText.length > DESCRIPTION_MOBILE_MAX_CHARS,
223 },
224 }
225 })
226
227 return (
228 <Section>
229 <SectionDescription>
230 See how your title tag and meta description may look in Google search
231 results. Data is read from the current page.
232 </SectionDescription>
233 <For each={SERP_PREVIEWS}>
234 {(preview) => {
235 const issues = createMemo(() =>
236 getSerpIssues(serp(), serpPreviewState().overflow, [
237 ...COMMON_CHECKS,
238 ...preview.extraChecks,
239 ]),
240 )
241
242 return (
243 <SerpSnippetPreview
244 data={serp()}
245 displayTitle={serpPreviewState().displayTitle}
246 displayDescription={serpPreviewState().displayDescription}
247 isMobile={preview.isMobile}
248 label={preview.label}
249 issues={issues()}
250 />
251 )
252 }}
253 </For>
254 </Section>
255 )
256}

Callers

nothing calls this directly

Calls 5

createHeadChangesFunction · 0.90
getSerpFromHeadFunction · 0.85
truncateToCharsFunction · 0.85
getSerpIssuesFunction · 0.85
issuesFunction · 0.85

Tested by

no test coverage detected