|
1 | | -import { For, createSignal } from 'solid-js' |
| 1 | +import { createSignal, For } from 'solid-js' |
| 2 | +import { useStyles } from '../../styles/use-styles' |
| 3 | +import { useHeadChanges } from '../../hooks/use-head-changes' |
2 | 4 | import { |
3 | | - MainPanel, |
4 | 5 | Section, |
5 | 6 | SectionDescription, |
6 | 7 | SectionIcon, |
7 | 8 | SectionTitle, |
8 | 9 | } from '@tanstack/devtools-ui' |
9 | 10 | import { SocialBubble } from '@tanstack/devtools-ui/icons' |
10 | | -import { useStyles } from '../styles/use-styles' |
11 | | -import { useHeadChanges } from '../hooks/use-head-changes' |
12 | | - |
13 | | -type SocialMeta = { |
14 | | - title?: string |
15 | | - description?: string |
16 | | - image?: string |
17 | | - url?: string |
18 | | -} |
19 | | - |
20 | | -type SocialReport = { |
21 | | - network: string |
22 | | - found: Partial<SocialMeta> |
23 | | - missing: Array<string> |
24 | | -} |
25 | 11 |
|
26 | 12 | const SOCIALS = [ |
27 | 13 | { |
@@ -96,6 +82,20 @@ const SOCIALS = [ |
96 | 82 | }, |
97 | 83 | // Add more networks as needed |
98 | 84 | ] |
| 85 | + |
| 86 | +type SocialMeta = { |
| 87 | + title?: string |
| 88 | + description?: string |
| 89 | + image?: string |
| 90 | + url?: string |
| 91 | +} |
| 92 | + |
| 93 | +type SocialReport = { |
| 94 | + network: string |
| 95 | + found: Partial<SocialMeta> |
| 96 | + missing: Array<string> |
| 97 | +} |
| 98 | + |
99 | 99 | function SocialPreview(props: { |
100 | 100 | meta: SocialMeta |
101 | 101 | color: string |
@@ -145,7 +145,8 @@ function SocialPreview(props: { |
145 | 145 | </div> |
146 | 146 | ) |
147 | 147 | } |
148 | | -export const SeoTab = () => { |
| 148 | + |
| 149 | +export function SocialPreviewSection() { |
149 | 150 | const [reports, setReports] = createSignal<Array<SocialReport>>(analyzeHead()) |
150 | 151 | const styles = useStyles() |
151 | 152 |
|
@@ -182,51 +183,49 @@ export const SeoTab = () => { |
182 | 183 | }) |
183 | 184 |
|
184 | 185 | return ( |
185 | | - <MainPanel withPadding> |
186 | | - <Section> |
187 | | - <SectionTitle> |
188 | | - <SectionIcon> |
189 | | - <SocialBubble /> |
190 | | - </SectionIcon> |
191 | | - Social previews |
192 | | - </SectionTitle> |
193 | | - <SectionDescription> |
194 | | - See how your current page will look when shared on popular social |
195 | | - networks. The tool checks for essential meta tags and highlights any |
196 | | - that are missing. |
197 | | - </SectionDescription> |
198 | | - <div class={styles().seoPreviewSection}> |
199 | | - <For each={reports()}> |
200 | | - {(report, i) => { |
201 | | - const social = SOCIALS[i()] |
202 | | - return ( |
203 | | - <div> |
204 | | - <SocialPreview |
205 | | - meta={report.found} |
206 | | - color={social!.color} |
207 | | - network={social!.network} |
208 | | - /> |
209 | | - {report.missing.length > 0 ? ( |
210 | | - <> |
211 | | - <div class={styles().seoMissingTagsSection}> |
212 | | - <strong>Missing tags for {social?.network}:</strong> |
| 186 | + <Section> |
| 187 | + <SectionTitle> |
| 188 | + <SectionIcon> |
| 189 | + <SocialBubble /> |
| 190 | + </SectionIcon> |
| 191 | + Social previews |
| 192 | + </SectionTitle> |
| 193 | + <SectionDescription> |
| 194 | + See how your current page will look when shared on popular social |
| 195 | + networks. The tool checks for essential meta tags and highlights any |
| 196 | + that are missing. |
| 197 | + </SectionDescription> |
| 198 | + <div class={styles().seoPreviewSection}> |
| 199 | + <For each={reports()}> |
| 200 | + {(report, i) => { |
| 201 | + const social = SOCIALS[i()] |
| 202 | + return ( |
| 203 | + <div> |
| 204 | + <SocialPreview |
| 205 | + meta={report.found} |
| 206 | + color={social!.color} |
| 207 | + network={social!.network} |
| 208 | + /> |
| 209 | + {report.missing.length > 0 ? ( |
| 210 | + <> |
| 211 | + <div class={styles().seoMissingTagsSection}> |
| 212 | + <strong>Missing tags for {social?.network}:</strong> |
213 | 213 |
|
214 | | - <ul class={styles().seoMissingTagsList}> |
215 | | - <For each={report.missing}> |
216 | | - {(tag) => ( |
217 | | - <li class={styles().seoMissingTag}>{tag}</li> |
218 | | - )} |
219 | | - </For> |
220 | | - </ul> |
221 | | - </div> |
222 | | - </> |
223 | | - ) : null} |
224 | | - </div> |
225 | | - ) |
226 | | - }} |
227 | | - </For> |
228 | | - </div> |
229 | | - </Section> |
230 | | - </MainPanel> |
| 214 | + <ul class={styles().seoMissingTagsList}> |
| 215 | + <For each={report.missing}> |
| 216 | + {(tag) => ( |
| 217 | + <li class={styles().seoMissingTag}>{tag}</li> |
| 218 | + )} |
| 219 | + </For> |
| 220 | + </ul> |
| 221 | + </div> |
| 222 | + </> |
| 223 | + ) : null} |
| 224 | + </div> |
| 225 | + ) |
| 226 | + }} |
| 227 | + </For> |
| 228 | + </div> |
| 229 | + </Section> |
231 | 230 | ) |
232 | 231 | } |
0 commit comments