Skip to content

Commit

Permalink
Merge branch 'main' into tina/nov-ug-livestream-link-update
Browse files Browse the repository at this point in the history
  • Loading branch information
babakamyljanovssw authored Nov 20, 2024
2 parents 83677f1 + 6dd7e61 commit 5f23920
Show file tree
Hide file tree
Showing 31 changed files with 1,208 additions and 221 deletions.
148 changes: 148 additions & 0 deletions app/articles/[filename]/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
"use client";

import ArticleAuthor from "@/components/articles/articleAuthor";
import { componentRenderer } from "@/components/blocks/mdxComponentRenderer";
import { CallToAction } from "@/components/callToAction/callToAction";
import { PreFooter } from "@/components/layout/footer/pre-footer";
import SidebarPanel from "@/components/sidebar/sidebarPanel";
import { SectionColor } from "@/components/util/constants/styles";
import { Container } from "@/components/util/container";
import { Section } from "@/components/util/section";
import client from "@/tina/client";
import { Breadcrumbs } from "app/components/breadcrumb";
import classNames from "classnames";
import Image from "next/image";
import { tinaField } from "tinacms/dist/react";
import { TinaMarkdown } from "tinacms/dist/rich-text";
export type ArticleData = Awaited<
ReturnType<typeof client.queries.articlesContentQuery>
>;

export type ArticlePageProps = {
tinaProps: { data: ArticleData["data"] };
props: { filename: string; indexPageTitle: string };
};

const ArticlePage = ({ props, tinaProps }: ArticlePageProps) => {
const { data } = tinaProps;
const showCallToAction = data.articles.callToAction.showCallToAction;
const azureBannerColor = showCallToAction
? SectionColor.Default
: SectionColor.LightGray;
const { author } = data.articles;
return (
<>
{data.articles.bannerImg && (
<Container className="prose flex-1" size="custom">
<div data-tina-field={tinaField(data.articles, "bannerImg")}>
<Image
src={data.articles.bannerImg}
width={1312}
height={0}
alt="SSW Industry Banner"
sizes="100vw"
/>
</div>
</Container>
)}
{data.articles.seo?.showBreadcrumb === null ||
(data.articles.seo?.showBreadcrumb && (
<Section className="mx-auto w-full max-w-9xl px-8 py-5">
<Breadcrumbs
path={props.filename}
title={data.articles.seo?.title}
seoSchema={data.articles.seo}
additionalReplacements={[
{
from: "articles",
to: props.indexPageTitle,
},
]}
/>
</Section>
))}

{data.articles.title && (
<Section
className="mx-auto w-full max-w-9xl px-8"
data-tina-field={tinaField(data.articles, "title")}
>
<h1 data-tina-field={tinaField} className="mt-4 py-2">
{data.articles.title}
</h1>
</Section>
)}
{!!data.articles.author && (
<Section className="mx-auto w-full max-w-9xl px-8">
<ArticleAuthor
name={author?.presenter?.name}
position={author?.position}
image={author?.profileImg}
url={author?.presenter?.peopleProfileURL}
/>
</Section>
)}
{data.articles.subTitle && (
<section
className={classNames(
"prose mx-auto w-full max-w-9xl flex-row px-8 pb-8 prose-h1:my-0 prose-h1:pt-8 prose-h2:mt-8 prose-img:my-0 lg:flex"
)}
>
<div data-tina-field={tinaField(data.articles, "subTitle")}>
<TinaMarkdown
content={data.articles.subTitle}
components={componentRenderer}
/>
</div>
{data.articles.sidebarPanel?.showSidebarPanel && (
<div className="w-full px-16 lg:shrink lg:pl-16 lg:pr-0">
<SidebarPanel
title={data.articles.sidebarPanel?.title}
tinaFields={{
title: tinaField(data.articles.sidebarPanel, "title"),
description: tinaField(
data.articles.sidebarPanel,
"description"
),
}}
description={data.articles.sidebarPanel?.description}
actionUrl={data.articles.sidebarPanel?.actionUrl}
actionText={data.articles.sidebarPanel?.actionText}
/>
</div>
)}
</section>
)}

{data.articles.callToAction?.showCallToAction && (
<CallToAction
animated={data.articles?.callToAction?.animated}
tinaFields={{
subTitle: tinaField(data.articles?.callToAction, "subTitle"),
buttonSubtitle: tinaField(
data.articles?.callToAction,
"buttonSubtitle"
),
}}
subTitle={data.articles?.callToAction?.subTitle}
buttonText={data.articles?.callToAction?.buttonText}
buttonSubtitle={data.articles?.callToAction?.buttonSubtitle}
>
{data.articles?.callToAction?.title && (
<h2
className="callToAction"
data-tina-field={tinaField(data.articles?.callToAction, "title")}
>
{data.articles?.callToAction?.title}
</h2>
)}
</CallToAction>
)}
{data.articles.showAzureFooter && (
<PreFooter backgroundColor={azureBannerColor} />
)}
</>
);
};

export default ArticlePage;
53 changes: 53 additions & 0 deletions app/articles/[filename]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import client from "@/tina/client";
import { TinaClient, UseTinaProps } from "app/tina-client";
import { TODAY } from "hooks/useFetchEvents";
import { useSEO } from "hooks/useSeo";
import { Metadata } from "next";
import ArticlePage, { ArticleData, ArticlePageProps } from ".";
const getData = async (
filename: string
): Promise<{
props: UseTinaProps & ArticlePageProps["props"];
}> => {
const tinaProps = await getArticle(filename);
tinaProps.data.articlesIndex.title;
return {
props: {
data: tinaProps.data,
query: tinaProps.query,
variables: tinaProps.variables,
indexPageTitle: tinaProps.data.articlesIndex.title,
filename,
},
};
};

export async function generateMetadata({
params,
}: {
params: { filename: string };
}): Promise<Metadata> {
const tinaProps = await getArticle(params.filename);
const seo = tinaProps.data.articles.seo;
seo.canonical = `${tinaProps.data.global.header.url}articles/${params.filename}`;
// eslint-disable-next-line react-hooks/rules-of-hooks
const { seoProps } = useSEO(seo);
return {
...seoProps,
};
}
const getArticle = async (filename: string): Promise<ArticleData> => {
const data = await client.queries.articlesContentQuery({
relativePath: `${filename}.mdx`,
date: TODAY.toISOString(),
});
return data;
};

const Article = async ({ params }: { params: { filename: string } }) => {
const { props } = await getData(params.filename);

return <TinaClient Component={ArticlePage} props={props}></TinaClient>;
};

export default Article;
1 change: 0 additions & 1 deletion app/articles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function ArticlesIndexPage({ props, tinaProps }: ArticlesIndexPageProps) {
<></>
<Breadcrumbs
path={"articles"}
suffix={data.global.breadcrumbSuffix}
title={data.articlesIndex.title}
seoSchema={data.articlesIndex.seo}
/>
Expand Down
1 change: 0 additions & 1 deletion app/company/[filename]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function CompanyPage({ tinaProps, props }) {
<Section className="mx-auto min-h-24 w-full max-w-9xl px-8 py-5 md:min-h-16">
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global.breadcrumbSuffix}
title={data.company.seo?.title}
seoSchema={data.company.seo}
/>
Expand Down
1 change: 0 additions & 1 deletion app/company/clients/[filename]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default function CompanyPage({ tinaProps, props }) {
<Section className="mx-auto min-h-24 w-full max-w-9xl px-8 py-5 md:min-h-16">
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global.breadcrumbSuffix}
title={data.caseStudy.seo?.title}
seoSchema={data.caseStudy.seo}
/>
Expand Down
1 change: 0 additions & 1 deletion app/company/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default function CompanyIndexPage({ props, tinaProps }) {
<Section className="mx-auto w-full max-w-9xl px-8 py-5">
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global.breadcrumbSuffix}
title={data.companyIndex.seo?.title}
seoSchema={data.companyIndex.seo}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/company/partners/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function PartnersIndex({ tinaProps }) {
return (
<>
<Container className="mb-10 flex-1 pt-2">
<Breadcrumbs path={"/Partners"} suffix="" title={"Partners"} />
<Breadcrumbs path={"/Partners"} title={"Partners"} />
<h1 className="mb-0 py-0 text-3xl">{data.partnerIndex.title}</h1>
<h2 className="mb-4 text-base">{data.partnerIndex.subTitle}</h2>
<div className="flex flex-col md:flex-row">
Expand Down
20 changes: 14 additions & 6 deletions app/components/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ import React, { FC } from "react";
import { tinaField } from "tinacms/dist/react";

interface BreadcrumbsProps {
additionalReplacements?: { from: string; to: string }[];
path: string;
suffix: string;
title: string;
seoSchema?: {
title?: string;
};
}
export const Breadcrumbs: FC<BreadcrumbsProps> = (props) => {
export const Breadcrumbs: FC<BreadcrumbsProps> = ({
additionalReplacements = [],
path,
title,
seoSchema,
}) => {
const listItemStyling =
"breadcrumb_item inline text-xs text-gray-700 no-underline not-first:before:content-bread not-first:before:px-2 before:list-none";

if (path && title) {
additionalReplacements.push({ from: path, to: `${title}` });
}
return (
<div
{...(props.seoSchema
? { "data-tina-field": tinaField(props.seoSchema, "title") }
{...(seoSchema
? { "data-tina-field": tinaField(seoSchema, "title") }
: {})}
>
<NextBreadcrumbs
Expand All @@ -37,7 +44,8 @@ export const Breadcrumbs: FC<BreadcrumbsProps> = (props) => {
{ from: "clients", to: "Clients" },
{ from: "live", to: "Live" },
{ from: "logo", to: "Logo" },
{ from: props.path, to: `${props.title}` },
{ from: "articles", to: "Articles" },
...additionalReplacements,
]}
useDefaultStyle={true}
activeItemClassName={listItemStyling}
Expand Down
1 change: 0 additions & 1 deletion app/consulting/[filename]/consulting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default function Consulting({ tinaProps, props }) {
<Section className="mx-auto min-h-24 w-full max-w-9xl px-8 py-5 md:min-h-16">
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global.breadcrumbSuffix}
title={data.consulting.seo?.title}
seoSchema={data.consulting.seo}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/consulting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function ConsultingIndex({ tinaProps }) {
<>
<Container className="flex-1 pt-2">
<div className="min-h-8 w-full max-w-9xl md:min-h-12">
<Breadcrumbs path={"/consulting"} suffix="" title={"Services"} />
<Breadcrumbs path={"/consulting"} title={"Services"} />
</div>
<h1 className="pt-0 text-3xl">Consulting Services</h1>
<div className="flex flex-col md:flex-row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function VideoProductionPage({ props, tinaProps }) {
<Section className="mx-auto w-full max-w-9xl px-8 py-5">
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global.breadcrumbSuffix}
title={data.videoProduction.seo?.title}
seoSchema={data.videoProduction.seo}
/>
Expand Down
1 change: 0 additions & 1 deletion app/events/[filename]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default function EventsPage({ props, tinaProps }) {
>
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global?.breadcrumbSuffix}
title={data.events?.seo?.title}
/>
</div>
Expand Down
1 change: 0 additions & 1 deletion app/events/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function EventsIndexPage({ props, tinaProps }) {
<Section className="mx-auto min-h-24 w-full max-w-9xl px-8 py-5 md:min-h-16">
<Breadcrumbs
path={removeExtension(props.variables.relativePath)}
suffix={data.global.breadcrumbSuffix}
title={data.eventsIndex.seo?.title}
seoSchema={data.eventsIndex.seo}
/>
Expand Down
1 change: 0 additions & 1 deletion app/products/[filename]/products-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default function ProductsContent({ props }) {
<Section className="mx-auto w-full max-w-9xl px-8 pt-5">
<Breadcrumbs
path={removeExtension(variables.relativePath)}
suffix={data.global?.breadcrumbSuffix}
title={data.products?.seo?.title}
/>
</Section>
Expand Down
2 changes: 1 addition & 1 deletion app/products/products-index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function ProductsIndexContent({ props }) {
return (
<>
<Container className="mb-10 flex-1 pt-2">
<Breadcrumbs path={"/products"} suffix="" title={"Products"} />
<Breadcrumbs path={"/products"} title={"Products"} />
{props.productsIndex.title && (
<h1
props-tina-field={tinaField(props.productsIndex, "title")}
Expand Down
9 changes: 7 additions & 2 deletions components/layout/footer/pre-footer.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { BuiltOnAzure } from "@/components/blocks/builtOnAzure";
import { SectionColor } from "@/components/util/constants/styles";
import { Section } from "@/components/util/section";

export const PreFooter = () => {
export const PreFooter = ({
backgroundColor = SectionColor.LightGray,
}: {
backgroundColor?: SectionColor;
}) => {
return (
<Section className="w-full flex-none">
<BuiltOnAzure data={{ backgroundColor: "lightgray" }} />
<BuiltOnAzure data={{ backgroundColor }} />
</Section>
);
};
7 changes: 7 additions & 0 deletions components/util/constants/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ export const sectionColors = {
red: "bg-sswRed text-white",
black: "bg-black text-white",
};

export enum SectionColor {
Default = "default",
LightGray = "lightgray",
Red = "red",
Black = "black",
}
Loading

0 comments on commit 5f23920

Please sign in to comment.