a
This commit is contained in:
@@ -6,7 +6,7 @@ import type {
|
||||
PlatformId
|
||||
} from './types'
|
||||
|
||||
export function getDefaultPlatforms(): Record<PlatformId, { name: string; icon: string; rateLimit: number; enabled: boolean }> {
|
||||
export function getDefaultPlatforms(): Record<PlatformId, { name: string; icon: string; rateLimit: number; enabled: boolean; searchTemplate: string }> {
|
||||
return {
|
||||
reddit: {
|
||||
name: 'Reddit',
|
||||
@@ -285,7 +285,7 @@ function buildRecommendationQueries(
|
||||
}))
|
||||
}
|
||||
|
||||
const SITE_OPERATORS: Record<PlatformId, string> = {
|
||||
const SITE_OPERATORS: Record<string, string> = {
|
||||
reddit: 'site:reddit.com',
|
||||
twitter: 'site:twitter.com OR site:x.com',
|
||||
hackernews: 'site:news.ycombinator.com',
|
||||
@@ -295,7 +295,7 @@ const SITE_OPERATORS: Record<PlatformId, string> = {
|
||||
linkedin: 'site:linkedin.com',
|
||||
}
|
||||
|
||||
const DEFAULT_TEMPLATES: Record<PlatformId, string> = {
|
||||
const DEFAULT_TEMPLATES: Record<string, string> = {
|
||||
reddit: '{site} {term} {intent}',
|
||||
twitter: '{site} {term} {intent}',
|
||||
hackernews: '{site} ("Ask HN" OR "Show HN") {term} {intent}',
|
||||
@@ -310,15 +310,18 @@ function applyTemplate(template: string, vars: Record<string, string>): string {
|
||||
}
|
||||
|
||||
function buildPlatformQuery(
|
||||
platform: { id: PlatformId; searchTemplate?: string },
|
||||
platform: { id: PlatformId; searchTemplate?: string; site?: string },
|
||||
term: string,
|
||||
intent: string
|
||||
): string {
|
||||
const template = (platform.searchTemplate && platform.searchTemplate.trim().length > 0)
|
||||
? platform.searchTemplate
|
||||
: DEFAULT_TEMPLATES[platform.id]
|
||||
: DEFAULT_TEMPLATES[platform.id] ?? '{site} {term} {intent}'
|
||||
const siteOperator = platform.site && platform.site.trim().length > 0
|
||||
? `site:${platform.site.trim()}`
|
||||
: (SITE_OPERATORS[platform.id] ?? '')
|
||||
const raw = applyTemplate(template, {
|
||||
site: SITE_OPERATORS[platform.id],
|
||||
site: siteOperator,
|
||||
term,
|
||||
intent,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user