Skip to content

Commit 9b699c8

Browse files
authored
Merge pull request #157 from Saigon-Digital/seo-fix
SEO fix
2 parents d340730 + 0cc1fa7 commit 9b699c8

File tree

8 files changed

+29
-17
lines changed

8 files changed

+29
-17
lines changed

frontend/src/components/ImageContent/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const ImageContent = ({
1717
reverse,
1818
fullWidthLayout,
1919
}: ImageContentBlock) => {
20-
console.log("content", content)
2120
const params = useRouter().asPath
2221
const ref = useRef<HTMLDivElement>(null)
2322
const scrollTo = (element: RefObject<HTMLDivElement>) => {

frontend/src/components/RichText/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import React from "react";
33
import { twMerge } from "tailwind-merge";
44

55
const RichText: React.FC<RichTextFragment> = (props) => {
6-
console.log(props.richText);
7-
86
return (
97
<section className="container-block pb-14 ">
108
<div className="grid grid-cols-12 gap-y-10 px-5">

frontend/src/components/SEO/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ export type TSEO = {
1010
defaultSEO?: SiteSettingFragment | null | undefined
1111
link?: string | null | undefined
1212
pageTitle?: string
13+
slug: string
14+
canonical: string
1315
}
1416
const SEO = (props: TSEO) => {
17+
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || ""
1518
const {seo: onPageSeo, link, defaultSEO, DEUri, ENUri} = props
1619
const favicon = defaultSEO?.favicon?.node?.sourceUrl
1720

@@ -21,9 +24,10 @@ const SEO = (props: TSEO) => {
2124
image:
2225
onPageSeo?.socialGraphImage?.node?.sourceUrl ||
2326
defaultSEO?.openGraphImage?.node.sourceUrl,
24-
seoCanonical: onPageSeo?.canonicalUrl || link?.replace("homepage/", ""),
25-
url: link?.replace("homepage/", ""),
27+
seoCanonical: props.canonical,
28+
url: props.canonical,
2629
}
30+
console.log('canonical', seo?.seoCanonical)
2731

2832
return (
2933
<Head>

frontend/src/data/site_data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

frontend/src/data/site_map.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

frontend/src/pages/[...wordpressNode].tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ export default function Page(props: WordPressTemplateProps) {
77
}
88

99
export const getStaticProps: GetStaticProps = async (ctx) => {
10-
1110
return getWordPressProps({
1211
ctx,
13-
1412
});
1513
};
1614

frontend/src/pages/blog/[slug].tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,30 @@ type Props = {
2323
siteSetting: SiteSettingFragment;
2424
};
2525
host?: string;
26+
slug: string;
2627
};
27-
const index = ({blog, relatedBlog, locale, host, siteSettings}: Props) => {
28+
const index = ({blog, relatedBlog, locale, host, siteSettings, slug}: Props) => {
2829
const event = new Date(blog.dateGmt || new Date().getTime());
2930
const localeStr =
3031
locale?.toLocaleUpperCase() === LanguageCodeFilterEnum.En
3132
? "en-EN"
3233
: "de-DE";
3334
let siteTitle = blog.title + " | Vulcanus Stahl";
3435
let link = host + `/${locale}` + "/blog" + blog.uri;
35-
let DEUri = host + `/de` + "/blog" + blog.uri;
36-
let ENUri = host + `/en` + "/blog" + blog.uri;
36+
37+
const enUrl = `${process.env.NEXT_PUBLIC_SITE_URL || ""}/en${slug}`
38+
const deUrl = `${process.env.NEXT_PUBLIC_SITE_URL || ""}${slug}`
39+
3740
return (
3841
<>
3942
<SEO
4043
link={link}
41-
DEUri={DEUri}
42-
ENUri={ENUri}
44+
DEUri={deUrl}
45+
ENUri={enUrl}
4346
defaultSEO={{...siteSettings.siteSetting, siteTitle: siteTitle}}
4447
seo={blog.pagesSetting}
48+
slug={slug}
49+
canonical={locale === "de" ? deUrl : enUrl}
4550
/>
4651
<main className=" py-20 pb-10 lg:py-0 lg:pb-0">
4752
<div className="mx-auto mb-10 flex max-w-[912px] flex-col gap-6 px-5 lg:mb-20">
@@ -98,6 +103,7 @@ export const getServerSideProps = (async (context) => {
98103
host,
99104
siteSettings: siteSettings,
100105
hideLanguageToggle:true,
106+
slug: `/blog/${slug}`,
101107
},
102108
};
103109
}) satisfies GetServerSideProps<{

frontend/src/wp-templates/page.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SEO from "@/components/SEO"
1010

1111
const Page: FaustTemplate<GetPageQuery> = (props) => {
1212
// Loading state for previews
13+
const router = useRouter()
1314
if (props.loading) {
1415
return <>Loading...</>
1516
}
@@ -26,16 +27,22 @@ const Page: FaustTemplate<GetPageQuery> = (props) => {
2627
let socialLink =
2728
process.env.NEXT_PUBLIC_SITE_URL +
2829
(props?.data?.page?.translation?.uri ?? "")
29-
// console.log(socialLink)
30+
31+
const slug = router.asPath === "/" ? "" : router.asPath
32+
const enUrl = `${process.env.NEXT_PUBLIC_SITE_URL || ""}/en${slug}`
33+
const deUrl = `${process.env.NEXT_PUBLIC_SITE_URL || ""}${slug}`
34+
const locale = router.locale
3035

3136
return (
3237
<>
3338
<SEO
34-
DEUri={props?.data?.page?.translation?.DELang?.link}
35-
ENUri={props.data?.page?.translation?.ENLang?.link}
39+
DEUri={deUrl}
40+
ENUri={enUrl}
3641
seo={props?.data?.page?.translation?.pagesSetting}
3742
defaultSEO={{...siteSetting?.siteSetting, siteTitle: siteTitle}}
3843
link={socialLink}
44+
slug={slug}
45+
canonical={locale === "de" ? deUrl : enUrl}
3946
/>
4047

4148
<BlockViewer dynamicBlocks={dynamicBlocks} />

0 commit comments

Comments
 (0)