mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem The UI was missing several common SEO affordances, including: - canonical URLs - JSON+LD structured data (`TechArticle`, `BreadcrumbList`) - a sitemap Also the [examples pages](https://supabase.com/library/example/password-based-auth/auth/sign-up) should be tagged with `noindex` b/c they're demo webpages. ## Solution Adds these + adds the newly created sitemap to the apps/www listing. ## Preview links ### Sitemap https://ui-library-git-kody-devrel-815-seo-tweaks-ui-library-supabase.vercel.app/library/sitemap.xml <img width="1338" height="669" alt="image" src="https://github.com/user-attachments/assets/75bdbfa0-1294-4ed2-a045-fc76d2c8f133" /> ### Canonical URLs Also fixed a bug in the og:url property, where it didn't set the `/library` and instead rendered `undefined`. **Previous** https://supabase.com/library/docs/nextjs/password-based-auth <img width="1338" height="702" alt="image" src="https://github.com/user-attachments/assets/90561e30-f5b0-4a91-b19d-340b542c996d" /> **New** https://ui-library-git-kody-devrel-815-seo-tweaks-ui-library-supabase.vercel.app/library/docs/nextjs/password-based-auth <img width="1338" height="702" alt="image" src="https://github.com/user-attachments/assets/2bdf34b2-2cc2-4b50-b57b-807835ba5d01" /> ### JSON-LD - [preview](https://ui-library-git-kody-devrel-815-seo-tweaks-ui-library-supabase.vercel.app/library/docs/nextjs/password-based-auth) - [validation](https://validator.schema.org/#url=https%3A%2F%2Fui-library-git-kody-devrel-815-seo-tweaks-ui-library-supabase.vercel.app%2Flibrary%2Fdocs%2Fnextjs%2Fpassword-based-auth) <img width="1338" height="702" alt="image" src="https://github.com/user-attachments/assets/25627028-c37a-4940-ad6d-0d85d31f3ef9" /> ### Examples Now have a `noindex` value on them. https://ui-library-git-kody-devrel-815-seo-tweaks-ui-library-supabase.vercel.app/library/example/password-based-auth/auth/sign-up <img width="1338" height="702" alt="image" src="https://github.com/user-attachments/assets/16f30d8c-8471-43e0-a55c-e6dc30e326e0" />
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { breadcrumbListSchema, serializeJsonLd, techArticleSchema } from './json-ld'
|
|
|
|
describe('serializeJsonLd', () => {
|
|
it('escapes characters that could break out of the script tag', () => {
|
|
const out = serializeJsonLd({ name: '</script><b>&' })
|
|
expect(out).not.toContain('<')
|
|
expect(out).not.toContain('>')
|
|
expect(out).not.toContain('&')
|
|
expect(JSON.parse(out)).toEqual({ name: '</script><b>&' })
|
|
})
|
|
})
|
|
|
|
describe('techArticleSchema', () => {
|
|
it('ties the article to its canonical URL', () => {
|
|
const schema = techArticleSchema({
|
|
url: 'https://supabase.com/library/docs/nextjs/dropzone',
|
|
headline: 'Dropzone (File Upload)',
|
|
description: 'Drag-and-drop uploads.',
|
|
})
|
|
expect(schema).toMatchObject({
|
|
'@type': 'TechArticle',
|
|
'@id': 'https://supabase.com/library/docs/nextjs/dropzone#page',
|
|
url: 'https://supabase.com/library/docs/nextjs/dropzone',
|
|
mainEntityOfPage: {
|
|
'@type': 'WebPage',
|
|
'@id': 'https://supabase.com/library/docs/nextjs/dropzone',
|
|
},
|
|
headline: 'Dropzone (File Upload)',
|
|
description: 'Drag-and-drop uploads.',
|
|
})
|
|
})
|
|
|
|
it('omits the description when none is given', () => {
|
|
const schema = techArticleSchema({ url: 'https://supabase.com/library/docs/x', headline: 'X' })
|
|
expect(schema.description).toBeUndefined()
|
|
})
|
|
})
|
|
|
|
describe('breadcrumbListSchema', () => {
|
|
it('numbers items from the root down', () => {
|
|
const schema = breadcrumbListSchema([
|
|
{ name: 'Supabase Library', url: 'https://supabase.com/library' },
|
|
{ name: 'Dropzone', url: 'https://supabase.com/library/docs/nextjs/dropzone' },
|
|
])
|
|
expect(schema.itemListElement).toEqual([
|
|
{
|
|
'@type': 'ListItem',
|
|
position: 1,
|
|
name: 'Supabase Library',
|
|
item: 'https://supabase.com/library',
|
|
},
|
|
{
|
|
'@type': 'ListItem',
|
|
position: 2,
|
|
name: 'Dropzone',
|
|
item: 'https://supabase.com/library/docs/nextjs/dropzone',
|
|
},
|
|
])
|
|
})
|
|
})
|