Unverified Commit 9870faf7 authored by Gabriel F's avatar Gabriel F Committed by GitHub

Fix export function name on docs/routing/layouts-and-templates (#65240)

### What?
Fix export function name on docs/routing/layouts-and-templates

### Why?
The way it is, it will return an error to the user following the
tutorial: `Unsupported Server Component type: undefined / next js 13`

### How?
- Change `Links()` function export to `NavLinks()`

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent a0df9860
...@@ -229,7 +229,7 @@ Since `usePathname()` is a client hook, you need to extract the nav links into a ...@@ -229,7 +229,7 @@ Since `usePathname()` is a client hook, you need to extract the nav links into a
import { usePathname } from 'next/navigation' import { usePathname } from 'next/navigation'
import Link from 'next/link' import Link from 'next/link'
export function Links() { export function NavLinks() {
const pathname = usePathname() const pathname = usePathname()
return ( return (
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
[Turso](https://turso.tech) is a SQLite-compatible database built on libSQL, the Open Contribution fork of SQLite. It enables scaling to hundreds of thousands of databases per organization and supports replication to any location, including your own servers, for microsecond-latency access. [Turso](https://turso.tech) is a SQLite-compatible database built on libSQL, the Open Contribution fork of SQLite. It enables scaling to hundreds of thousands of databases per organization and supports replication to any location, including your own servers, for microsecond-latency access.
* [Turso Documentation](https://docs.turso.tech) - [Turso Documentation](https://docs.turso.tech)
* [Turso Support](https://discord.com/invite/4B5D7hYwub) - [Turso Support](https://discord.com/invite/4B5D7hYwub)
## Features ## Features
* Uses SQLite `dev.db` locally - Uses SQLite `dev.db` locally
* App Router - App Router
* Server Actions - Server Actions
## How to use ## How to use
...@@ -54,52 +54,52 @@ You can deploy this app to Vercel in a few simple steps: ...@@ -54,52 +54,52 @@ You can deploy this app to Vercel in a few simple steps:
1. **Signup to Turso** 1. **Signup to Turso**
Install the Turso CLI and login using GitHub: Install the Turso CLI and login using GitHub:
```bash ```bash
# macOS # macOS
brew install tursodatabase/tap/turso brew install tursodatabase/tap/turso
# Windows (WSL) & Linux: # Windows (WSL) & Linux:
# curl -sSfL https://get.tur.so/install.sh | bash # curl -sSfL https://get.tur.so/install.sh | bash
``` ```
2. **Create a database** 2. **Create a database**
Begin by creating your first database: Begin by creating your first database:
```bash ```bash
turso db create [database-name] turso db create [database-name]
``` ```
3. **Create a table** 3. **Create a table**
Connect to the turso shell and create your first table: Connect to the turso shell and create your first table:
```bash ```bash
turso db shell <database-name> turso db shell <database-name>
``` ```
```bash ```bash
CREATE TABLE todos(id INTEGER PRIMARY KEY AUTOINCREMENT, description TEXT NOT NULL) CREATE TABLE todos(id INTEGER PRIMARY KEY AUTOINCREMENT, description TEXT NOT NULL)
``` ```
4. **Retrieve database URL** 4. **Retrieve database URL**
You'll need to fetch your database URL and assign it to `TURSO_DB_URL` on deployment: You'll need to fetch your database URL and assign it to `TURSO_DB_URL` on deployment:
```bash ```bash
turso db show <database-name> --url turso db show <database-name> --url
``` ```
5. **Create database auth token** 5. **Create database auth token**
Now create an access token and assign it to `TURSO_DB_TOKEN` on deployment: Now create an access token and assign it to `TURSO_DB_TOKEN` on deployment:
```bash ```bash
turso db tokens create <database-name> turso db tokens create <database-name>
``` ```
6. **Deploy to Vercel** 6. **Deploy to Vercel**
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-turso&env=TURSO_DB_URL,TURSO_DB_TOKEN) [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-turso&env=TURSO_DB_URL,TURSO_DB_TOKEN)
import { TodoList } from './todo-list' import { TodoList } from "./todo-list";
import { Form } from "./form"; import { Form } from "./form";
export default function Home() { export default function Home() {
return ( return (
<main className="max-w-2xl mx-auto space-y-12 px-6 py-32"> <main className="max-w-2xl mx-auto space-y-12 px-6 py-32">
<div className="space-y-3 text-center"> <div className="space-y-3 text-center">
<h1 className="text-3xl font-medium">Turso</h1> <h1 className="text-3xl font-medium">Turso</h1>
<p className="text-gray-500">Local SQLite with libSQL and Turso</p> <p className="text-gray-500">Local SQLite with libSQL and Turso</p>
...@@ -14,6 +13,6 @@ export default function Home() { ...@@ -14,6 +13,6 @@ export default function Home() {
<TodoList /> <TodoList />
<Form /> <Form />
</div> </div>
</main > </main>
); );
} }
...@@ -5,15 +5,19 @@ import { db } from "@/lib/turso"; ...@@ -5,15 +5,19 @@ import { db } from "@/lib/turso";
// The code below can be removed in production apps // The code below can be removed in production apps
// Useful for getting started locally with SQLite // Useful for getting started locally with SQLite
async function findOrCreateTodosTable() { async function findOrCreateTodosTable() {
const result = await db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='todos'") const result = await db.execute(
"SELECT name FROM sqlite_master WHERE type='table' AND name='todos'",
);
if (!result || result?.rows?.length === 0) { if (!result || result?.rows?.length === 0) {
await db.execute("CREATE TABLE todos(id INTEGER PRIMARY KEY AUTOINCREMENT, description TEXT NOT NULL)") await db.execute(
"CREATE TABLE todos(id INTEGER PRIMARY KEY AUTOINCREMENT, description TEXT NOT NULL)",
);
} }
} }
export async function TodoList() { export async function TodoList() {
await findOrCreateTodosTable() await findOrCreateTodosTable();
const result = await db.execute("SELECT * FROM todos"); const result = await db.execute("SELECT * FROM todos");
const rows = result.rows as unknown as TodoItem[]; const rows = result.rows as unknown as TodoItem[];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment