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
......
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