Skip to content

Commit

Permalink
fix meta v2 docs types
Browse files Browse the repository at this point in the history
  • Loading branch information
chaance committed Mar 15, 2023
1 parent 0566611 commit bb75d33
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/route/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ This can get quite tricky when you're new.
Consider a route like `/projects/123`, there are likely three matching routes: `root.tsx`, `projects.tsx`, and `projects/$id.tsx`. All three may export meta descriptors.

```tsx bad filename=app/root.tsx
export const meta: MetaFunction = () => {
export const meta: V2_MetaFunction = () => {
return [
{
name: "viewport",
Expand All @@ -297,13 +297,13 @@ export const meta: MetaFunction = () => {
```

```tsx bad filename=app/routes/projects.tsx
export const meta: MetaFunction = () => {
export const meta: V2_MetaFunction = () => {
return [{ title: "Projects" }];
};
```

```tsx bad filename=app/routes/projects/$id.tsx
export const meta: MetaFunction<typeof loader> = ({
export const meta: V2_MetaFunction<typeof loader> = ({
data,
}) => {
return [{ title: data.project.name }];
Expand Down Expand Up @@ -354,7 +354,7 @@ You can also avoid the merge problem by simply not exporting meta that you want
Usually you only need to add meta to what the parent has already defined. You can merge parent meta with the spread operator and the [`matches`][matches] arg:

```tsx
export const meta: MetaFunction = ({ matches }) => {
export const meta: V2_MetaFunction = ({ matches }) => {
let parentMeta = matches.flatMap(
(match) => match.meta ?? []
);
Expand All @@ -365,7 +365,7 @@ export const meta: MetaFunction = ({ matches }) => {
Note that this _will not_ override something like `title`. This is only additive. If the inherited route meta includes a `title` tag, you can override with `Array.prototype.filter`:

```tsx
export const meta: MetaFunction = ({ matches }) => {
export const meta: V2_MetaFunction = ({ matches }) => {
let parentMeta = matches
.flatMap((match) => match.meta ?? [])
.filter((meta) => !("title" in meta));
Expand Down

0 comments on commit bb75d33

Please sign in to comment.