The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(docs): pull docs from external wrappers repo
Bo Lu739f3d4a4992
diff --git a/apps/docs/pages/guides/database/extensions/wrappers.mdx b/apps/docs/pages/guides/database/extensions/wrappers.mdxindex 5d99f88ea08..e19b099c1e3 100644--- a/apps/docs/pages/guides/database/extensions/wrappers.mdx+++ b/apps/docs/pages/guides/database/extensions/wrappers.mdx@@ -60,12 +60,13 @@ A web interface for connecting to external data is coming to Supabase Studio in## Integrations-- [Firebase](https://supabase.github.io/wrappers/firebase/)-- [Stripe](https://supabase.github.io/wrappers/stripe/)-- [BigQuery](https://supabase.github.io/wrappers/bigquery/)-- [AWS S3](https://supabase.github.io/wrappers/s3/)-- Airtable - Coming Soon-- Clickhouse - Coming Soon+- [Airtable](/docs/guides/database/extensions/wrappers/airtable)+- [AWS S3](/docs/guides/database/extensions/wrappers/s3)+- [BigQuery](/docs/guides/database/extensions/wrappers/bigquery)+- [ClickHouse](/docs/guides/database/extensions/wrappers/clickhouse)+- [Firebase](/docs/guides/database/extensions/wrappers/firebase)+- [Logflare](/docs/guides/database/extensions/wrappers/logflare)+- [Stripe](/docs/guides/database/extensions/wrappers/stripe)## Resourcesdiff --git a/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsx b/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsxnew file mode 100644index 00000000000..25249cecba4--- /dev/null+++ b/apps/docs/pages/guides/database/extensions/wrappers/[slug].tsx@@ -0,0 +1,178 @@+import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'+import { GetStaticPaths, GetStaticProps } from 'next'+import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'+import { serialize } from 'next-mdx-remote/serialize'+import { relative } from 'path'+import rehypeSlug from 'rehype-slug'+import remarkGfm from 'remark-gfm'+import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }+import components from '~/components'+import Layout from '~/layouts/DefaultGuideLayout'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'+import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'+import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'++// We fetch these docs at build time from an external repo+const org = 'supabase'+const repo = 'wrappers'+const branch = 'main'+const docsDir = 'docs'+const externalSite = 'https://supabase.github.io/wrappers'++// Each external docs page is mapped to a local page+const pageMap = [+ {+ slug: 'airtable',+ meta: {+ title: 'Airtable',+ },+ remoteFile: 'airtable.md',+ },+ {+ slug: 's3',+ meta: {+ title: 'AWS S3',+ },+ remoteFile: 's3.md',+ },+ {+ slug: 'bigquery',+ meta: {+ title: 'BigQuery',+ },+ remoteFile: 'bigquery.md',+ },+ {+ slug: 'clickhouse',+ meta: {+ title: 'ClickHouse',+ },+ remoteFile: 'clickhouse.md',+ },+ {+ slug: 'firebase',+ meta: {+ title: 'Firebase',+ },+ remoteFile: 'firebase.md',+ },+ {+ slug: 'logflare',+ meta: {+ title: 'Logflare',+ },+ remoteFile: 'logflare.md',+ },+ {+ slug: 'stripe',+ meta: {+ title: 'Stripe',+ },+ remoteFile: 'stripe.md',+ },+]++interface WrappersDocsProps {+ source: MDXRemoteSerializeResult+ meta: {+ title: string+ description?: string+ }+}++export default function WrappersDocs({ source, meta }: WrappersDocsProps) {+ return (+ <Layout meta={meta}>+ <MDXRemote {...source} components={components} />+ </Layout>+ )+}++/**+ * Fetch markdown from external repo and transform links+ */+export const getStaticProps: GetStaticProps<WrappersDocsProps> = async ({ params }) => {+ const page = pageMap.find(({ slug }) => slug === params.slug)++ if (!page) {+ throw new Error(`No page mapping found for slug '${params.slug}'`)+ }++ const { remoteFile, meta } = page++ const response = await fetch(+ `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`+ )++ const source = await response.text()++ const urlTransform: UrlTransformFunction = (url) => {+ try {+ const externalSiteUrl = new URL(externalSite)++ const placeholderHostname = 'placeholder'+ const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)++ // Don't modify a url with a FQDN or a url that's only a hash+ if (hostname !== placeholderHostname || pathname === '/') {+ return url+ }++ const relativePage = (+ pathname.endsWith('.md')+ ? pathname.replace(/\.md$/, '')+ : relative(externalSiteUrl.pathname, pathname)+ ).replace(/^\//, '')++ const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)++ // If we have a mapping for this page, use the mapped path+ if (page) {+ return page.slug + hash+ }++ // If we don't have this page in our docs, link to original docs+ return `${externalSite}/${relativePage}${hash}`+ } catch (err) {+ console.error('Error transforming markdown URL', err)+ return url+ }+ }++ const codeHikeOptions: CodeHikeConfig = {+ theme: codeHikeTheme,+ lineNumbers: true,+ showCopyButton: true,+ skipLanguages: [],+ autoImport: false,+ }++ const mdxSource = await serialize(source, {+ scope: {+ chCodeConfig: codeHikeOptions,+ },+ mdxOptions: {+ remarkPlugins: [+ remarkGfm,+ remarkMkDocsAdmonition,+ [removeTitle, meta.title],+ [remarkCodeHike, codeHikeOptions],+ ],+ rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],+ },+ })++ return { props: { source: mdxSource, meta } }+}++export const getStaticPaths: GetStaticPaths = async () => {+ return {+ paths: pageMap.map(({ slug }) => ({+ params: {+ slug,+ },+ })),+ fallback: false,+ }+}+