-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from agility/NextJS-15-Update
Next 15 Updates
- Loading branch information
Showing
30 changed files
with
435 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"no-html-link-for-pages": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export default function NotFound() { | ||
return ( | ||
<section className="relative px-8 "> | ||
<div className="max-w-2xl mx-auto my-12 md:mt-18 lg:mt-20 prose prose-sm sm:prose lg:prose-lg xl:prose-xl"> | ||
<h1>Page Not Found</h1> | ||
<p>The page you were looking for could not be found</p> | ||
</div> | ||
</section> | ||
) | ||
return ( | ||
<section className="relative px-8 "> | ||
<div className="max-w-2xl mx-auto my-12 md:mt-18 lg:mt-20 prose prose-sm sm:prose lg:prose-lg xl:prose-xl"> | ||
<h1>Page Not Found</h1> | ||
<p>The page you were looking for could not be found</p> | ||
</div> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,24 @@ | ||
import { getDynamicPageURL } from "@agility/nextjs/node"; | ||
import { revalidatePath, revalidateTag } from "next/cache"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { draftMode } from "next/headers" | ||
import { url } from "inspector"; | ||
|
||
export async function GET(req: NextRequest, res: NextResponse) { | ||
export async function GET(req: NextRequest) { | ||
|
||
const searchParams = req.nextUrl.searchParams | ||
const contentIDStr = searchParams.get("ContentID") as string | ||
|
||
const contentID = parseInt(contentIDStr) | ||
|
||
const preview = draftMode().isEnabled | ||
|
||
const { isEnabled: preview } = await draftMode() | ||
|
||
if (!isNaN(contentID) && contentID > 0) { | ||
//*** this is a dynamic page request *** | ||
//get the slug for this page based on the sitemap and redirect there | ||
const redirectUrl = await getDynamicPageURL({ contentID, preview, slug: "" }) | ||
if (redirectUrl) { | ||
return new Response(`Redirecting to Dynamic Page Item`, { | ||
status: 307, | ||
headers: { | ||
"Location": redirectUrl, | ||
} | ||
}); | ||
return NextResponse.redirect(redirectUrl, { status: 307, headers: { "Location": redirectUrl } }) | ||
} | ||
} | ||
|
||
//if we get here, it's a 404 | ||
return new Response(`Not Found`, { | ||
status: 404 | ||
}) | ||
return NextResponse.json({ message: "Not Found" }, { status: 404 }) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,34 @@ | ||
"use server"; | ||
import { getDynamicPageURL } from '@agility/nextjs/node'; | ||
import { draftMode } from 'next/headers' | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
export async function GET(request: NextRequest, res: NextResponse) { | ||
export async function GET(request: NextRequest) { | ||
|
||
const searchParams = request.nextUrl.searchParams | ||
|
||
const slug = searchParams.get('slug') | ||
const ContentID = searchParams.get('ContentID') | ||
const slug = searchParams.get('slug'); | ||
const ContentID = searchParams.get('ContentID'); | ||
|
||
//disable draft/preview mode | ||
draftMode().disable() | ||
(await draftMode()).disable() | ||
|
||
let url = `${slug}` | ||
let url = new URL(slug || '', request.nextUrl.origin).toString(); | ||
|
||
if (ContentID) { | ||
const dynamicPath = await getDynamicPageURL({ contentID: Number(ContentID), preview: false, slug: slug || undefined }); | ||
if (dynamicPath) { | ||
url = dynamicPath; | ||
} | ||
|
||
} | ||
|
||
// Redirect to the url | ||
if (url.includes("?")) { | ||
url = `${url}&preview=0` | ||
} else { | ||
url = `${url}?preview=0` | ||
} | ||
|
||
return new Response(`Exiting preview mode`, { | ||
status: 307, | ||
headers: { | ||
"Location": url, | ||
} | ||
// Remove the preview URL param if it exists | ||
const urlObj = new URL(url); | ||
urlObj.searchParams.delete('preview'); | ||
url = urlObj.toString(); | ||
|
||
}); | ||
|
||
NextResponse.redirect(url) | ||
// Redirect to the url | ||
return NextResponse.redirect(url, { status: 307, headers: { "Location": url } }) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.