-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Damian Stasik <[email protected]>
- Loading branch information
1 parent
b7adc89
commit 28cc36a
Showing
24 changed files
with
264 additions
and
51 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useEffect } from "react"; | ||
|
||
interface MetaTitleProps { | ||
children: string; | ||
} | ||
|
||
export function MetaTitle({ children }: MetaTitleProps) { | ||
useEffect(() => { | ||
document.title = `${children} - OpenTofu Registry`; | ||
|
||
return () => { | ||
document.title = "OpenTofu Registry"; | ||
}; | ||
}, [children]); | ||
|
||
return null; | ||
} |
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
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,38 @@ | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { getModuleDataQuery } from "../query"; | ||
|
||
import { MetaTitle } from "@/components/MetaTitle"; | ||
import { useModuleParams } from "../hooks/useModuleParams"; | ||
import { Suspense } from "react"; | ||
|
||
interface ModuleMetaTitleProps { | ||
page?: string; | ||
} | ||
|
||
function ModuleMetaTitleContent({ page }: ModuleMetaTitleProps) { | ||
const { namespace, name, target, version, isLatest } = useModuleParams(); | ||
|
||
const { data } = useSuspenseQuery( | ||
getModuleDataQuery(namespace, name, target), | ||
); | ||
|
||
let title = `${data.addr.namespace}/${data.addr.name}/${data.addr.target}`; | ||
|
||
if (!isLatest) { | ||
title = `${version} - ${title}`; | ||
} | ||
|
||
if (page) { | ||
title = `${page} - ${title}`; | ||
} | ||
|
||
return <MetaTitle>{title}</MetaTitle>; | ||
} | ||
|
||
export function ModuleMetaTitle({ page }: ModuleMetaTitleProps) { | ||
return ( | ||
<Suspense fallback={null}> | ||
<ModuleMetaTitleContent page={page} /> | ||
</Suspense> | ||
); | ||
} |
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
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
39 changes: 39 additions & 0 deletions
39
frontend/src/routes/ModuleExample/components/MetaTitle.tsx
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,39 @@ | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
|
||
import { MetaTitle } from "@/components/MetaTitle"; | ||
import { useModuleExampleParams } from "../hooks/useModuleExampleParams"; | ||
import { getModuleDataQuery } from "@/routes/Module/query"; | ||
import { Suspense } from "react"; | ||
|
||
interface ModuleMetaTitleProps { | ||
page?: string; | ||
} | ||
|
||
function ModuleExampleMetaTitleContent({ page }: ModuleMetaTitleProps) { | ||
const { namespace, name, target, version, isLatest, example } = | ||
useModuleExampleParams(); | ||
|
||
const { data } = useSuspenseQuery( | ||
getModuleDataQuery(namespace, name, target), | ||
); | ||
|
||
let title = `Example: ${example} - ${data.addr.namespace}/${data.addr.name}/${data.addr.target}`; | ||
|
||
if (!isLatest) { | ||
title = `${version} - ${title}`; | ||
} | ||
|
||
if (page) { | ||
title = `${page} - ${title}`; | ||
} | ||
|
||
return <MetaTitle>{title}</MetaTitle>; | ||
} | ||
|
||
export function ModuleExampleMetaTitle({ page }: ModuleMetaTitleProps) { | ||
return ( | ||
<Suspense fallback={null}> | ||
<ModuleExampleMetaTitleContent page={page} /> | ||
</Suspense> | ||
); | ||
} |
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
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
Oops, something went wrong.