The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(embeddings): custom heading slugs
Greg Richardson36aa0cc187f0
diff --git a/.github/workflows/search.yml b/.github/workflows/search.ymlindex b3d60d06629..b4631ceca5d 100644--- a/.github/workflows/search.yml+++ b/.github/workflows/search.yml@@ -9,7 +9,12 @@ on:- 'supabase/migrations/**'- 'apps/docs/**'- 'spec/**'- workflow_dispatch: {}+ workflow_dispatch:+ inputs:+ refresh:+ description: 'Refresh all pages'+ required: false+ type: booleanschedule:- cron: '0 0 * * *'@@ -46,6 +51,12 @@ jobs:- name: Run migrationsrun: npx supabase db push- - name: Refresh embeddings+ - name: Update embeddingsworking-directory: ./apps/docs+ if: ${{ !inputs.refresh }}run: npm run embeddings++ - name: Refresh embeddings+ working-directory: ./apps/docs+ if: ${{ inputs.refresh }}+ run: npm run embeddings:refreshdiff --git a/apps/docs/scripts/search/sources/markdown.ts b/apps/docs/scripts/search/sources/markdown.tsindex 851839a772b..ef51f95e593 100644--- a/apps/docs/scripts/search/sources/markdown.ts+++ b/apps/docs/scripts/search/sources/markdown.ts@@ -96,6 +96,23 @@ export function splitTreeBy(tree: Root, predicate: (node: Content) => boolean) {}, [])}+/**+ * Wrapped slug generator that also accounts for+ * custom anchors in the format:+ *+ * ```markdown+ * ### My Heading [#my-custom-anchor]+ * ```+ */+export function generateSlug(slugger: GithubSlugger, heading: string) {+ const match = heading.match(/\[#(.*)\]/)+ if (match) {+ const [, customAnchor] = match+ return slugger.slug(customAnchor)+ }+ return slugger.slug(heading)+}+/*** Processes MDX content for search indexing.* It extracts metadata, strips it of all JSX,@@ -142,7 +159,7 @@ export function processMdxForSearch(content: string): ProcessedMdx {const [firstNode] = tree.childrenconst heading = firstNode.type === 'heading' ? toString(firstNode) : undefined- const slug = heading ? slugger.slug(heading) : undefined+ const slug = heading ? generateSlug(slugger, heading) : undefinedreturn {content: toMarkdown(tree),