-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added nextjs metada
- Loading branch information
Showing
7 changed files
with
138 additions
and
46 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
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,32 +1,10 @@ | ||
"use client"; | ||
import {getToolByHref} from "@/config/tools"; | ||
import BuildCircleRoundedIcon from "@mui/icons-material/BuildCircleRounded"; | ||
import GridViewRoundedIcon from "@mui/icons-material/GridViewRounded"; | ||
import HomeRoundedIcon from "@mui/icons-material/HomeRounded"; | ||
import {BreadcrumbItem, Breadcrumbs} from "@nextui-org/react"; | ||
import {usePathname, useRouter} from "next/navigation"; | ||
export default function ToolLayout({children}: {children: React.ReactNode}) { | ||
const path = usePathname(); | ||
const tool = getToolByHref(path); | ||
const router = useRouter(); | ||
import Breadcrumb from "@/components/breadcrumb"; | ||
|
||
export default function ToolLayout({children}: {children: React.ReactNode}) { | ||
return ( | ||
<main className="h-screen overflow-auto px-2"> | ||
<Breadcrumbs className="flex justify-center mt-4"> | ||
<BreadcrumbItem href="/" startContent={<HomeRoundedIcon fontSize="small" />}> | ||
Home | ||
</BreadcrumbItem> | ||
|
||
<BreadcrumbItem href="/tools" startContent={<GridViewRoundedIcon fontSize="small" />}> | ||
Tools | ||
</BreadcrumbItem> | ||
{path.includes("/tools/") ? ( | ||
<BreadcrumbItem startContent={<BuildCircleRoundedIcon fontSize="small" />}> | ||
{tool?.title} | ||
</BreadcrumbItem> | ||
) : null} | ||
</Breadcrumbs> | ||
{children} | ||
</main> | ||
<> | ||
<Breadcrumb /> | ||
<main className="h-screen overflow-auto px-2">{children}</main> | ||
</> | ||
); | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
import {getToolByHref} from "@/config/tools"; | ||
import BuildCircleRoundedIcon from "@mui/icons-material/BuildCircleRounded"; | ||
import GridViewRoundedIcon from "@mui/icons-material/GridViewRounded"; | ||
import HomeRoundedIcon from "@mui/icons-material/HomeRounded"; | ||
import {BreadcrumbItem, Breadcrumbs} from "@nextui-org/react"; | ||
import {usePathname} from "next/navigation"; | ||
|
||
function Breadcrumb() { | ||
const path = usePathname(); | ||
const tool = getToolByHref(path); | ||
|
||
return ( | ||
<Breadcrumbs className="flex justify-center mt-4"> | ||
<BreadcrumbItem href="/" startContent={<HomeRoundedIcon fontSize="small" />}> | ||
Home | ||
</BreadcrumbItem> | ||
|
||
<BreadcrumbItem href="/tools" startContent={<GridViewRoundedIcon fontSize="small" />}> | ||
Tools | ||
</BreadcrumbItem> | ||
{path.includes("/tools/") ? ( | ||
<BreadcrumbItem startContent={<BuildCircleRoundedIcon fontSize="small" />}> | ||
{tool?.title} | ||
</BreadcrumbItem> | ||
) : null} | ||
</Breadcrumbs> | ||
); | ||
} | ||
|
||
export default Breadcrumb; |
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,2 +1,20 @@ | ||
export const isActive = (pathname: string | undefined | null, href: string) => | ||
pathname && pathname.startsWith(href); | ||
|
||
/** | ||
* | ||
* Get the pathname from the metadata state | ||
* This dives into async storage of promise state to get the pathname | ||
* | ||
* This is much more performant that using headers() from next as this doesn't opt out from the cache | ||
* @param state | ||
* | ||
* credit: https://github.com/vercel/next.js/discussions/50189#discussioncomment-9224262 | ||
*/ | ||
export const getPathnameFromMetadataState = (state: any): string => { | ||
const res = Object.getOwnPropertySymbols(state || {}) | ||
.map((p) => state[p]) | ||
.find((state) => state?.hasOwnProperty?.("urlPathname")); | ||
|
||
return res?.urlPathname.replace(/\?.+/, "") ?? ""; | ||
}; |