mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-15 06:35:20 -07:00
feat(search): add pagefind provider support
Add Pagefind indexing and browser search adapters behind a provider switch. This lets prebuild generate either Stork or Pagefind search artifacts and lets the existing search UI run against Pagefind while preserving scoped filters, excerpts, and result metadata.
This commit is contained in:
parent
727f84e4c2
commit
e1da6eb880
12 changed files with 690 additions and 65 deletions
64
test/prebuild/pagefind.test.js
Normal file
64
test/prebuild/pagefind.test.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
import {
|
||||
mapSitemapEntryToPagefindRecord,
|
||||
shouldIndexSitemapEntry
|
||||
} from '~/helpers/pagefind/index.js'
|
||||
|
||||
describe('Pagefind records', () => {
|
||||
it('should skip sitemap entries without searchable payloads', () => {
|
||||
expect( shouldIndexSitemapEntry({
|
||||
route: '/games',
|
||||
payload: {}
|
||||
}) ).toBe( false )
|
||||
})
|
||||
|
||||
it('should map benchmark entries to Pagefind records', () => {
|
||||
const record = mapSitemapEntryToPagefindRecord({
|
||||
route: '/app/example/benchmarks',
|
||||
payload: {
|
||||
app: {
|
||||
name: 'Example App',
|
||||
text: '✅ Native support',
|
||||
content: 'Runs fast on Apple Silicon',
|
||||
aliases: [ 'Example' ],
|
||||
tags: [ 'Utilities' ],
|
||||
status: 'no-in-progress',
|
||||
slug: 'example',
|
||||
category: {
|
||||
slug: 'system-tools',
|
||||
label: 'System Tools'
|
||||
},
|
||||
lastUpdated: {
|
||||
timestamp: 1234567890
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect( record ).toMatchObject({
|
||||
url: '/app/example/benchmarks',
|
||||
language: 'en',
|
||||
meta: {
|
||||
title: 'Example App Benchmarks',
|
||||
text: '✅ Native support',
|
||||
slug: 'example',
|
||||
categorySlug: 'system-tools',
|
||||
routeType: 'benchmarks',
|
||||
lastUpdatedTimestamp: '1234567890'
|
||||
},
|
||||
filters: {
|
||||
status: [ 'no_in_progress' ],
|
||||
category: [ 'system_tools' ],
|
||||
type: [ 'benchmarks' ]
|
||||
},
|
||||
sort: {
|
||||
updated: '1234567890'
|
||||
}
|
||||
})
|
||||
|
||||
expect( record.content ).toContain('Example App Benchmarks')
|
||||
expect( record.content ).toContain('Runs fast on Apple Silicon')
|
||||
expect( record.content ).toContain('Apple Silicon App Tested')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue