Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

957 B
Raw Blame
import '../utils/dotenv.js'

import path from 'node:path'
import { createClient } from '@supabase/supabase-js'
import { ingestMarkdown } from 'docs-search/ingest'

import { TABLE_NAME } from './supabase.js'

const { SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY } = process.env
if (!SUPABASE_URL || !SUPABASE_SERVICE_ROLE_KEY) {
  console.error('Missing SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY. Set them in .env.local.')
  process.exit(1)
}

ingestMarkdown({
  supabase: createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
    auth: { autoRefreshToken: false, persistSession: false },
  }),
  table: TABLE_NAME,
  contentRoot: path.resolve(process.cwd(), 'public/markdown'),
  include: ['**/*.md'],
  // listing pages (the sitemap and one per topic) only link to the content that's already indexed
  ignore: ['sitemap.md', 'topics/**'],
  slugPrefix: 'kb/',
}).catch((err) => {
  console.error(err instanceof Error ? err.message : err)
  process.exit(1)
})