Skip to content

Commit

Permalink
Merge pull request #513 from damien-schneider/upgrade-nextra-doc-to-v3.2
Browse files Browse the repository at this point in the history
Upgrade nextra doc to v3.2
  • Loading branch information
psteinroe authored Nov 15, 2024
2 parents 2349efd + c97010b commit 3a1f88d
Show file tree
Hide file tree
Showing 24 changed files with 1,731 additions and 1,024 deletions.
11 changes: 0 additions & 11 deletions docs/next.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions docs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('next').NextConfig} */

import nextra from 'nextra';

const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx',
});

export default withNextra();
10 changes: 5 additions & 5 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"dependencies": {
"@vercel/analytics": "^1.0.0",
"next": "14.2.0",
"nextra": "2.13.2",
"nextra-theme-docs": "2.13.2",
"nextra": "3.2.0",
"nextra-theme-docs": "3.2.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
"typescript": "5.5.3",
"@types/node": "20.14.10",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"autoprefixer": "^10.4.13",
"postcss": "^8.4.14",
"tailwindcss": "3.4.0"
"tailwindcss": "3.4.0",
"typescript": "5.6.3"
}
}
8 changes: 0 additions & 8 deletions docs/pages/_meta.json

This file was deleted.

8 changes: 8 additions & 0 deletions docs/pages/_meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
index: {
title: 'Introduction',
},
configuration: 'Configuration',
postgrest: 'PostgREST',
storage: 'Storage',
};
11 changes: 5 additions & 6 deletions docs/pages/configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Callout, Tabs, Tab } from "nextra-theme-docs";
import Link from "next/link";
import { Callout, Tabs } from 'nextra/components';

# Configuration

Supabase Cache Helpers does a decent job at keeping your data up-to-date. This allows you to deviate from the standard configuration and reduce the number of requests to your backend while keeping your app fresh.

<Tabs items={['SWR', 'React Query']}>
<Tab>
<Tabs.Tab>
```tsx
function Page() {
return (
Expand All @@ -21,10 +20,10 @@ Supabase Cache Helpers does a decent job at keeping your data up-to-date. This a
)
}
```
</Tab>
<Tab>
</Tabs.Tab>
<Tabs.Tab>
```tsx
// TODO
```
</Tab>
</Tabs.Tab>
</Tabs>
2 changes: 1 addition & 1 deletion docs/pages/index.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Callout } from "nextra-theme-docs";
import { Callout } from 'nextra/components'

# Supabase Cache Helpers

Expand Down
8 changes: 0 additions & 8 deletions docs/pages/postgrest/_meta.json

This file was deleted.

8 changes: 8 additions & 0 deletions docs/pages/postgrest/_meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
'getting-started': 'Getting Started',
queries: 'Queries',
mutations: 'Mutations',
subscriptions: 'Subscriptions',
'custom-cache-updates': 'Custom Cache Updates',
ssr: 'Server Side Rendering',
};
19 changes: 9 additions & 10 deletions docs/pages/postgrest/custom-cache-updates.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Callout, Tabs, Tab } from "nextra-theme-docs";
import Link from "next/link";
import { Callout, Tabs } from 'nextra/components';

# Custom Cache Updates

Expand All @@ -10,7 +9,7 @@ Sometimes, you will find yourself writing custom cache updates. The library expo
Delete a postgrest entity from the cache. Note that you have to pass a value for all primary keys in the input.

<Tabs items={['SWR', 'React Query']}>
<Tab>
<Tabs.Tab>
```tsx
import { useDeleteItem } from "@supabase-cache-helpers/postgrest-swr";

Expand All @@ -26,8 +25,8 @@ Delete a postgrest entity from the cache. Note that you have to pass a value for
}
```

</Tab>
<Tab>
</Tabs.Tab>
<Tabs.Tab>
```tsx
import { useDeleteItem } from "@supabase-cache-helpers/postgrest-react-query";

Expand All @@ -43,15 +42,15 @@ Delete a postgrest entity from the cache. Note that you have to pass a value for
}
```

</Tab>
</Tabs.Tab>
</Tabs>

## `useUpsertItem`

Upsert a postgrest entity into the cache. Note that you have to pass a value for all primary keys in the input.

<Tabs items={['SWR', 'React Query']}>
<Tab>
<Tabs.Tab>
```tsx
import { useUpsertItem } from "@supabase-cache-helpers/postgrest-swr";

Expand All @@ -67,8 +66,8 @@ Upsert a postgrest entity into the cache. Note that you have to pass a value for
}
```

</Tab>
<Tab>
</Tabs.Tab>
<Tabs.Tab>
```tsx
import { useUpsertItem } from "@supabase-cache-helpers/postgrest-react-query";

Expand All @@ -84,5 +83,5 @@ Upsert a postgrest entity into the cache. Note that you have to pass a value for
}
```

</Tab>
</Tabs.Tab>
</Tabs>
31 changes: 15 additions & 16 deletions docs/pages/postgrest/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Callout, Tabs, Tab } from "nextra-theme-docs";
import Link from "next/link";
import { Callout, Tabs } from 'nextra/components';

# Getting Started

Expand All @@ -14,16 +13,16 @@ pnpm add @supabase-cache-helpers/postgrest-swr
If your package manager does not install peer dependencies automatically, you will need to install them, too.

<Tabs items={["SWR", "React Query"]}>
<Tab>`pnpm add swr react @supabase/postgrest-js`</Tab>
<Tab>`pnpm add @tanstack/react-query react @supabase/postgrest-js`</Tab>
<Tabs.Tab>`pnpm add swr react @supabase/postgrest-js`</Tabs.Tab>
<Tabs.Tab>`pnpm add @tanstack/react-query react @supabase/postgrest-js`</Tabs.Tab>
</Tabs>

## Quick Start

Import [`useQuery`](./queries#usequery) and define a simple query. The cache key is automatically created from the query. You can pass the SWR- and React Query-native options as a second argument. For pagination and infinite scroll queries, use [`useInfiniteOffsetPaginationQuery`](./queries#useinfiniteoffsetpaginationquery), [`useOffsetInfiniteScrollQuery`](./queries#useoffsetinfinitescrollquery) and [`useCursorInfiniteScrollQuery`](./queries#usecursorinfinitescrollquery).

<Tabs items={['SWR', 'React Query']}>
<Tab>
<Tabs.Tab>
```tsx
import { useQuery } from "@supabase-cache-helpers/postgrest-swr";

Expand All @@ -49,8 +48,8 @@ Import [`useQuery`](./queries#usequery) and define a simple query. The cache key
}
```

</Tab>
<Tab>
</Tabs.Tab>
<Tabs.Tab>
```tsx
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";

Expand All @@ -75,13 +74,13 @@ Import [`useQuery`](./queries#usequery) and define a simple query. The cache key
}
```

</Tab>
</Tabs.Tab>
</Tabs>

Somewhere in your app, import [`useInsertMutation`](./mutations#useinsertmutation) and define a mutation. For the automatic cache population to work, you need to pass the primary key(s) of the relation as a second argument. To return data from the mutation, pass a `.select('...')` string as the third argument. Pass `null` to skip. The fourth argument is the SWR- and React Query-native `options` object. The mutation will automatically update the query cache of the contact query defined above. Other operations are supported with [`useUpsertMutation`](./mutations#useupsertmutation), [`useUpdateMutation`](./mutations#useupdatemutation) and [`useDeleteMutation`](./mutations#usedeletemutation).

<Tabs items={['SWR', 'React Query']}>
<Tab>
<Tabs.Tab>
```tsx
import { useInsertMutation } from "@supabase-cache-helpers/postgrest-swr";

Expand All @@ -103,8 +102,8 @@ Somewhere in your app, import [`useInsertMutation`](./mutations#useinsertmutatio
}
```

</Tab>
<Tab>
</Tabs.Tab>
<Tabs.Tab>
```tsx
import { useInsertMutation } from "@supabase-cache-helpers/postgrest-react-query";

Expand All @@ -126,15 +125,15 @@ Somewhere in your app, import [`useInsertMutation`](./mutations#useinsertmutatio
}
```

</Tab>
</Tabs.Tab>
</Tabs>

To subscribe to changes, import [`useSubscription`](./subscriptions#usesubscription) and define a subscription. Use any channel name, and define the subscription as you know it from the Supabase client. For the automatic cache population to work, you need to pass the primary key(s) of the relation. You can pass the SWR and React Query-native mutation options.

The query cache will automatically be updated when new data comes in. If you use [computed / virtual columns](https://postgrest.org/en/stable/api.html?highlight=computed%20columns#computed-virtual-columns) or relations, you can use [`useSubscriptionQuery`](./subscriptions#usesubscriptionquery) to fetch the entity from `PostgREST` before populating the cache with it.

<Tabs items={['SWR', 'React Query']}>
<Tab>
<Tabs.Tab>
```tsx
import { useSubscription } from "@supabase-cache-helpers/postgrest-swr";

Expand All @@ -159,8 +158,8 @@ The query cache will automatically be updated when new data comes in. If you use
}
```

</Tab>
<Tab>
</Tabs.Tab>
<Tabs.Tab>
```tsx
import { useSubscription } from "@supabase-cache-helpers/postgrest-react-query";

Expand All @@ -185,5 +184,5 @@ The query cache will automatically be updated when new data comes in. If you use
}
```

</Tab>
</Tabs.Tab>
</Tabs>
Loading

0 comments on commit 3a1f88d

Please sign in to comment.