mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: menu links issue
This commit is contained in:
parent
fee546cbd0
commit
02a5ed6354
2 changed files with 19 additions and 5 deletions
|
|
@ -6,10 +6,15 @@ import learnhouseIcon from "public/learnhouse_icon.png";
|
||||||
import learnhouseLogo from "public/learnhouse_logo.png";
|
import learnhouseLogo from "public/learnhouse_logo.png";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useRouter, useSearchParams } from "next/navigation";
|
import { useRouter, useSearchParams, usePathname } from "next/navigation";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
|
import { getOrgFromUri, getUriWithOrg } from "@services/config";
|
||||||
|
|
||||||
|
export const Menu = (params : any) => {
|
||||||
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
const orgslug = getOrgFromUri(pathname);
|
||||||
|
|
||||||
export const Menu = ({ orgslug }: any) => {
|
|
||||||
return (
|
return (
|
||||||
<GlobalHeader>
|
<GlobalHeader>
|
||||||
<LogoArea>
|
<LogoArea>
|
||||||
|
|
@ -29,14 +34,14 @@ export const Menu = ({ orgslug }: any) => {
|
||||||
<MenuArea>
|
<MenuArea>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<Link href={"/courses"}>Courses</Link>
|
<Link href={getUriWithOrg(orgslug, "/courses")}>Courses</Link>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Link href={"/collections"}>Collections</Link>
|
<Link href={getUriWithOrg(orgslug, "/collections")}>Collections</Link>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{" "}
|
{" "}
|
||||||
<Link href={"/activity"}>Activity</Link>
|
<Link href={getUriWithOrg(orgslug, "/activity")}>Activity</Link>
|
||||||
</li>
|
</li>
|
||||||
<li>More</li>
|
<li>More</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,12 @@ const LEARNHOUSE_BACKEND_URL = "http://localhost:1338/";
|
||||||
export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
||||||
|
|
||||||
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
||||||
|
|
||||||
|
export const getUriWithOrg = ( orgslug: string, path: string) => {
|
||||||
|
return `http://localhost:3000/org/${orgslug}${path}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getOrgFromUri = (uri: any) => {
|
||||||
|
let org = uri.match(/\/org\/(.*?)\//)[1];
|
||||||
|
return org;
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue