Skip to content

Commit f58b76f

Browse files
define url entity type for passing in link data props
Signed-off-by: Michael Valdron <[email protected]>
1 parent f7db282 commit f58b76f

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

apps/landing-page/pages/_app.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ function LandingPage({ Component, pageProps }: AppProps): JSX.Element {
118118
<Footer
119119
websiteName={websiteName}
120120
websiteDescription={websiteDescription}
121-
lfTrademarkUsageUrl={lfTrademarkUsageUrl}
121+
lfTrademarkUsageLink={{
122+
href: lfTrademarkUsageUrl,
123+
text: lfTrademarkUsageUrl.replace(/http:\/\/|https:\/\//g, ''),
124+
}}
122125
/>
123126
</div>
124127
</NavigationProvider>

apps/registry-viewer/pages/_app.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ function CustomApp({ Component, pageProps }: AppProps): JSX.Element {
3939
<Header websiteName={websiteName} />
4040
<Component {...pageProps} />
4141
</div>
42-
<Footer websiteName={websiteName} lfTrademarkUsageUrl={lfTrademarkUsageUrl} />
42+
<Footer
43+
websiteName={websiteName}
44+
lfTrademarkUsageLink={{
45+
href: lfTrademarkUsageUrl,
46+
text: lfTrademarkUsageUrl.replace(/http:\/\/|https:\/\//g, ''),
47+
}}
48+
/>
4349
</div>
4450
</LinksProvider>
4551
</AnalyticsProvider>

libs/core/src/components/footer/footer.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
import Link from 'next/link';
1818
import { DevfileIcon } from '../../icons';
1919
import { useLinks } from '../../hooks';
20+
import { LinkProp } from '../../types/props';
2021

2122
export interface FooterProps {
2223
websiteName: string;
2324
websiteDescription?: string;
24-
lfTrademarkUsageUrl?: string;
25+
lfTrademarkUsageLink?: LinkProp;
2526
}
2627

2728
export function Footer(props: FooterProps): JSX.Element {
28-
const { websiteName, websiteDescription, lfTrademarkUsageUrl } = props;
29+
const { websiteName, websiteDescription, lfTrademarkUsageLink } = props;
2930

3031
const { footerNavigation } = useLinks();
3132

@@ -49,18 +50,18 @@ export function Footer(props: FooterProps): JSX.Element {
4950
{websiteDescription && (
5051
<p className="text-base text-slate-500 dark:text-slate-400">{websiteDescription}</p>
5152
)}
52-
{lfTrademarkUsageUrl && (
53+
{lfTrademarkUsageLink && (
5354
<p className="text-base text-slate-500 dark:text-slate-400">
5455
Copyright © Devfile a Series of LF Projects, LLC
5556
<br />
5657
For website terms of use, trademark policy and other project policies please
5758
see&nbsp;
5859
<Link
59-
href={lfTrademarkUsageUrl}
60+
href={lfTrademarkUsageLink.href}
6061
className="text-base text-slate-500 hover:text-slate-600 dark:text-slate-400 dark:hover:text-slate-300"
6162
target="_blank"
6263
>
63-
{lfTrademarkUsageUrl.replace(/https:\/\/|http:\/\//g, '')}
64+
{lfTrademarkUsageLink.text}
6465
</Link>
6566
.
6667
</p>

libs/core/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616

1717
export { Convert as ConvertDevfileSpec, type DevfileSpec } from './devfile-spec';
1818
export * from './custom-404';
19+
export * from './props';

libs/core/src/types/props.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright Red Hat
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Interface of a URL entity object
19+
*/
20+
export interface UrlEntity {
21+
text: string;
22+
href: string;
23+
}
24+
25+
/**
26+
* Type of Link property fields
27+
*/
28+
export type LinkProp = UrlEntity;

0 commit comments

Comments
 (0)