diff --git a/extensions/theme/src/layouts/pages/Static/Navigation.tsx b/extensions/theme/src/layouts/pages/Static/Navigation.tsx
index 32b676d080..c98b962f62 100644
--- a/extensions/theme/src/layouts/pages/Static/Navigation.tsx
+++ b/extensions/theme/src/layouts/pages/Static/Navigation.tsx
@@ -1,44 +1,46 @@
import React from "react";
import { Link } from "@webiny/react-router";
-import { PublishedMenuData } from "@webiny/app-website";
+import { PublishedMenuData, PublishedMenuItemData } from "@webiny/app-website";
import styled from "@emotion/styled";
export const Navigation: React.ComponentType<{ data?: PublishedMenuData }> = ({ data }) => {
if (!data) {
return null;
}
- const { items } = data;
return (
- {items?.map((item, index) => {
- if (Array.isArray(item.children)) {
- return (
-
- {item.title}
-
- {item.children.map((item, index) => (
-
- {item.title}
-
- ))}
-
-
- );
- }
-
- // We only use the Link component if the item has a `path` or `url` value.
- const link = item.path || item.url;
- return (
-
- {link ? {item.title} : item.title}
-
- );
- })}
+ {data.items?.map((item, index) => (
+
+ ))}
);
};
+const NavigationLi = ({ item }: { item: PublishedMenuItemData }) => {
+ if (Array.isArray(item.children) && item.children.length > 0) {
+ return (
+
+ {item.title}
+
+ {item.children.map((item, index) => (
+
+ ))}
+
+
+ );
+ }
+
+ let title = <>{item.title}>;
+
+ // We only use the Link component if the item has a `path` or `url` value.
+ if (item.path || item.url) {
+ title = {title};
+ }
+
+ return {title} ;
+};
+
const NavigationUl = styled.ul`
display: flex;
justify-content: flex-end;
@@ -74,12 +76,11 @@ const NavigationUl = styled.ul`
li {
margin: 0;
- padding: 0;
+ padding: 10px;
}
a {
display: inline-block;
- padding: 10px;
width: 100%;
box-sizing: border-box;
}
diff --git a/packages/app-website/src/Menu.tsx b/packages/app-website/src/Menu.tsx
index 82ec956049..8fd500ffe5 100644
--- a/packages/app-website/src/Menu.tsx
+++ b/packages/app-website/src/Menu.tsx
@@ -2,21 +2,18 @@ import * as React from "react";
import gql from "graphql-tag";
import { useQuery } from "@apollo/react-hooks";
+export interface PublishedMenuItemData {
+ id: string;
+ title: string;
+ path: string;
+ url: string;
+ children: PublishedMenuItemData;
+}
+
export interface PublishedMenuData {
title: string;
slug: string;
- items: Array<{
- id: string;
- title: string;
- path: string;
- url: string;
- children: Array<{
- id: string;
- title: string;
- path: string;
- url: string;
- }>;
- }>;
+ items: PublishedMenuItemData[];
}
export interface PublishedMenuError {
diff --git a/packages/cwp-template-aws/template/common/extensions/theme/src/layouts/pages/Static/Navigation.tsx b/packages/cwp-template-aws/template/common/extensions/theme/src/layouts/pages/Static/Navigation.tsx
index 64af0043c1..c00a8a26eb 100644
--- a/packages/cwp-template-aws/template/common/extensions/theme/src/layouts/pages/Static/Navigation.tsx
+++ b/packages/cwp-template-aws/template/common/extensions/theme/src/layouts/pages/Static/Navigation.tsx
@@ -1,44 +1,46 @@
import React from "react";
import { Link } from "@webiny/react-router";
-import { PublishedMenuData } from "@webiny/app-website";
+import { PublishedMenuData, PublishedMenuItemData } from "@webiny/app-website";
import styled from "@emotion/styled";
export const Navigation: React.ComponentType<{ data?: PublishedMenuData }> = ({ data }) => {
if (!data) {
return null;
}
- const { items } = data;
return (
- {items?.map((item, index) => {
- if (Array.isArray(item.children)) {
- return (
-
- {item.title}
-
- {item.children.map((item, index) => (
-
- {item.title}
-
- ))}
-
-
- );
- }
-
- // We only use the Link component if the item has a `path` or `url` value.
- const link = item.path || item.url;
- return (
-
- {link ? {item.title} : item.title}
-
- );
- })}
+ {data.items?.map((item, index) => (
+
+ ))}
);
};
+const NavigationLi = ({ item }: { item: PublishedMenuItemData }) => {
+ if (Array.isArray(item.children) && item.children.length > 0) {
+ return (
+
+ {item.title}
+
+ {item.children.map((item, index) => (
+
+ ))}
+
+
+ );
+ }
+
+ let title = <>{item.title}>;
+
+ // We only use the Link component if the item has a `path` or `url` value.
+ if (item.path || item.url) {
+ title = {title};
+ }
+
+ return {title} ;
+};
+
const NavigationUl = styled.ul`
display: flex;
justify-content: flex-end;
@@ -74,12 +76,11 @@ const NavigationUl = styled.ul`
li {
margin: 0;
- padding: 0;
+ padding: 10px;
}
a {
display: inline-block;
- padding: 10px;
width: 100%;
box-sizing: border-box;
}