The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(vecs): remove duplicate title from md
Greg Richardson545776845131
diff --git a/apps/docs/lib/mdx/rehypeLinkTransform.ts b/apps/docs/lib/mdx/plugins/rehypeLinkTransform.tssimilarity index 78%rename from apps/docs/lib/mdx/rehypeLinkTransform.tsrename to apps/docs/lib/mdx/plugins/rehypeLinkTransform.tsindex 90a3fde05af..5eab44f885d 100644--- a/apps/docs/lib/mdx/rehypeLinkTransform.ts+++ b/apps/docs/lib/mdx/plugins/rehypeLinkTransform.ts@@ -16,6 +16,11 @@ function modify(node: Element, prop: string, fn?: UrlTransformFunction) {}}+/**+ * Transforms every HAST element that contains a `href` or `src`.+ * A `UrlTransformFunction` is called with the current URL. The+ * return value from this function will be used as the replacement.+ */export function linkTransform(fn?: UrlTransformFunction) {return function transformer(tree: Node) {visit(tree, 'element', (node: Element) => {diff --git a/apps/docs/lib/mdx/plugins/remarkRemoveTitle.ts b/apps/docs/lib/mdx/plugins/remarkRemoveTitle.tsnew file mode 100644index 00000000000..3dcce035b60--- /dev/null+++ b/apps/docs/lib/mdx/plugins/remarkRemoveTitle.ts@@ -0,0 +1,23 @@+import { Parent } from 'mdast'++/**+ * Removes the top heading from a MD file if+ * it is the first node and it matches `title`.+ *+ * Useful when rendering title separately from MD+ * and you need to remove the duplicate.+ */+export function removeTitle(title: string) {+ return function transformer(root: Parent) {+ const [firstNode] = root.children++ if (firstNode?.type === 'heading') {+ const [text] = firstNode.children++ if (text?.type === 'text' && text.value === title) {+ // Remove this node+ root.children.splice(0, 1)+ }+ }+ }+}diff --git a/apps/docs/pages/guides/ai/python/[slug].tsx b/apps/docs/pages/guides/ai/python/[slug].tsxindex 07804e27db3..48525b10dd2 100644--- a/apps/docs/pages/guides/ai/python/[slug].tsx+++ b/apps/docs/pages/guides/ai/python/[slug].tsx@@ -6,7 +6,8 @@ import rehypeSlug from 'rehype-slug'import remarkGfm from 'remark-gfm'import components from '~/components'import Layout from '~/layouts/DefaultGuideLayout'-import { UrlTransformFunction, linkTransform } from '~/lib/mdx/rehypeLinkTransform'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'+import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'// We fetch these docs at build time from an external repoconst org = 'supabase'@@ -116,7 +117,7 @@ export const getStaticProps: GetStaticProps<PythonClientDocsProps> = async ({ paconst mdxSource = await serialize(source, {mdxOptions: {- remarkPlugins: [remarkGfm],+ remarkPlugins: [remarkGfm, [removeTitle, meta.title]],rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],},})