brease-client 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -128,15 +128,17 @@ Sources may use parameters as in Next's redirects (`/blog/:slug`, `/docs/:rest*`
|
|
|
128
128
|
|
|
129
129
|
`route()` also resolves other forms of a page's URL (`/en/about` where English has no prefix, `/about` where every
|
|
130
130
|
locale is prefixed); `resolvedSeo.canonical` points search engines at the real one. To redirect those forms too,
|
|
131
|
-
add this to the same proxy, before `NextResponse.next()`:
|
|
131
|
+
add this to the same proxy, before `NextResponse.next()`. Keep it in the `try`: when Brease can't be reached, the
|
|
132
|
+
request goes on to the page instead of failing.
|
|
132
133
|
|
|
133
134
|
```ts
|
|
134
135
|
import { canonicalPath } from 'brease-client'
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
const canonical = canonicalPath(
|
|
138
|
-
if (canonical && (await brease.getPages()).some((p) => p.url === canonical))
|
|
139
|
-
|
|
137
|
+
try {
|
|
138
|
+
const canonical = canonicalPath(await brease.getSite(), req.nextUrl.pathname)
|
|
139
|
+
if (canonical && (await brease.getPages()).some((p) => p.url === canonical))
|
|
140
|
+
return NextResponse.redirect(new URL(canonical + req.nextUrl.search, req.url), 308)
|
|
141
|
+
} catch {}
|
|
140
142
|
```
|
|
141
143
|
|
|
142
144
|
### Structured data (JSON-LD)
|
package/dist/index.d.cts
CHANGED
|
@@ -123,12 +123,12 @@ interface Brease {
|
|
|
123
123
|
getPage<T = Record<string, unknown>>(slug: string, opts: {
|
|
124
124
|
locale: string;
|
|
125
125
|
}): Promise<Page<T> | null>;
|
|
126
|
-
getPages(opts?: {
|
|
126
|
+
getPages<T = Record<string, unknown>>(opts?: {
|
|
127
127
|
locale?: string;
|
|
128
128
|
parentId?: string;
|
|
129
129
|
template?: string;
|
|
130
130
|
withContent?: boolean;
|
|
131
|
-
}): Promise<PageRef[]>;
|
|
131
|
+
}): Promise<PageRef<T>[]>;
|
|
132
132
|
getNavigation(key: string, opts: {
|
|
133
133
|
locale: string;
|
|
134
134
|
}): Promise<Navigation | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -123,12 +123,12 @@ interface Brease {
|
|
|
123
123
|
getPage<T = Record<string, unknown>>(slug: string, opts: {
|
|
124
124
|
locale: string;
|
|
125
125
|
}): Promise<Page<T> | null>;
|
|
126
|
-
getPages(opts?: {
|
|
126
|
+
getPages<T = Record<string, unknown>>(opts?: {
|
|
127
127
|
locale?: string;
|
|
128
128
|
parentId?: string;
|
|
129
129
|
template?: string;
|
|
130
130
|
withContent?: boolean;
|
|
131
|
-
}): Promise<PageRef[]>;
|
|
131
|
+
}): Promise<PageRef<T>[]>;
|
|
132
132
|
getNavigation(key: string, opts: {
|
|
133
133
|
locale: string;
|
|
134
134
|
}): Promise<Navigation | null>;
|