Skip to content

Commit 790d0f1

Browse files
authored
Merge pull request #24 from keepsimpleio/chore/longevity-og-image
chore: add og image for Longevity
2 parents b25e673 + d3f816f commit 790d0f1

12 files changed

Lines changed: 38 additions & 13 deletions

File tree

711 KB
Loading

src/components/SeoGenerator/SeoGenerator.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface SeoGeneratorProps {
1313
localizedSlug?: any;
1414
modifiedDate?: string;
1515
createdDate?: string;
16+
isLongevityPage?: boolean;
1617
ogTags?: {
1718
ogDescription: string;
1819
ogTitle: string;
@@ -38,6 +39,7 @@ const SeoGenerator: FC<SeoGeneratorProps> = ({
3839
createdDate,
3940
modifiedDate,
4041
localizedSlug,
42+
isLongevityPage,
4143
}) => {
4244
const router = useRouter();
4345

@@ -224,7 +226,9 @@ const SeoGenerator: FC<SeoGeneratorProps> = ({
224226
property="og:image"
225227
content={
226228
ogTags?.ogImage?.data?.attributes?.url
227-
? `${process.env.NEXT_PUBLIC_STRAPI}${ogTags?.ogImage?.data?.attributes?.url}`
229+
? isLongevityPage
230+
? ogTags?.ogImage?.data?.attributes?.url
231+
: `${process.env.NEXT_PUBLIC_STRAPI}${ogTags?.ogImage?.data?.attributes?.url}`
228232
: ogTags?.ogImage?.data?.attributes?.staticUrl
229233
}
230234
/>
@@ -254,7 +258,9 @@ const SeoGenerator: FC<SeoGeneratorProps> = ({
254258
name="twitter:image"
255259
content={
256260
ogTags?.ogImage?.data?.attributes?.url
257-
? `${process.env.NEXT_PUBLIC_STRAPI}${ogTags?.ogImage?.data?.attributes?.url}`
261+
? isLongevityPage
262+
? ogTags?.ogImage?.data?.attributes?.url
263+
: `${process.env.NEXT_PUBLIC_STRAPI}${ogTags?.ogImage?.data?.attributes?.url}`
258264
: ogTags?.ogImage?.data?.attributes?.staticUrl
259265
}
260266
/>

src/constants/longevity.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ export const longevityDietPath = '/keepsimple_/assets/longevity/diet';
22
const heartsPath = '/keepsimple_/assets/longevity/diet/hearts/';
33
const scaleImgPath = '/keepsimple_/assets/longevity/diet/diet-results-icons/';
44
const backgroundImgPath = '/keepsimple_/assets/longevity/diet/diet-results-bg/';
5-
5+
const domain = process.env.NEXT_PUBLIC_DOMAIN;
6+
export const ogImage = `${domain}/keepsimple_/assets/longevity/og.png`;
67
export const images = [
78
`${heartsPath}sugar.svg`,
89
`${heartsPath}seed-oil.svg`,
@@ -144,7 +145,7 @@ export const ACTIVITY_LEVEL_SUMMARY = [
144145
minutes: 300,
145146
riskOfDyingEarly: '65% of early-death risk',
146147
cognitiveDecline: '~25–35% lower',
147-
brainAgingActive: 'Optimized (use brain-age model)',
148+
brainAgingActive: 'Optimized',
148149
brainAgingSedentary: 'Worst-case brain-age path',
149150
},
150151
];

src/pages/tools/longevity-protocol/about-project.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getWhatIsThis } from '@api/longevity/what-is-this';
44
import SeoGenerator from '@components/SeoGenerator';
55

66
import WhatIsThisLayout from '@layouts/LongevityLayouts';
7+
import { ogImage } from '@constants/longevity';
78

89
const AboutProject = ({ aboutTheProject }) => {
910
const OGTags = {
@@ -14,7 +15,7 @@ const AboutProject = ({ aboutTheProject }) => {
1415
ogImage: {
1516
data: {
1617
attributes: {
17-
url: aboutTheProject['en']?.ogImage?.data?.attributes?.url || '',
18+
url: ogImage,
1819
},
1920
},
2021
},
@@ -29,6 +30,7 @@ const AboutProject = ({ aboutTheProject }) => {
2930
title: aboutTheProject['en']?.Seo?.pageTitle || '',
3031
seoTitle: aboutTheProject['en']?.Seo?.seoTitle || '',
3132
}}
33+
isLongevityPage
3234
ogTags={OGTags}
3335
createdDate={aboutTheProject['en']?.createdAt || ''}
3436
modifiedDate={aboutTheProject['en']?.updatedAt || ''}

src/pages/tools/longevity-protocol/environment.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import EnvironmentLayout from '@layouts/EnvironmentLayout/EnvironmentLayout';
55

66
import { getEnvironment } from '@api/longevity/environment';
77
import SeoGenerator from '@components/SeoGenerator';
8+
import { ogImage } from '@constants/longevity';
89

910
const Environment = ({ environment }) => {
1011
const router = useRouter();
@@ -18,7 +19,7 @@ const Environment = ({ environment }) => {
1819
ogImage: {
1920
data: {
2021
attributes: {
21-
url: environment['en']?.ogImage?.data?.attributes?.url || '',
22+
url: ogImage,
2223
},
2324
},
2425
},
@@ -33,6 +34,7 @@ const Environment = ({ environment }) => {
3334
title: environment['en']?.Seo?.pageTitle || '',
3435
seoTitle: environment['en']?.Seo?.seoTitle || '',
3536
}}
37+
isLongevityPage
3638
ogTags={OGTags}
3739
createdDate={environment['en']?.createdAt || ''}
3840
modifiedDate={environment['en']?.updatedAt || ''}

src/pages/tools/longevity-protocol/habits/diet.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DietLayout from '@layouts/DietLayout';
44

55
import { getDiet } from '@api/longevity/diet';
66
import SeoGenerator from '@components/SeoGenerator';
7+
import { ogImage } from '@constants/longevity';
78

89
const Diet = ({ dietData }) => {
910
const OGTags = {
@@ -14,7 +15,7 @@ const Diet = ({ dietData }) => {
1415
ogImage: {
1516
data: {
1617
attributes: {
17-
url: dietData['en']?.ogImage?.data?.attributes?.url || '',
18+
url: ogImage,
1819
},
1920
},
2021
},
@@ -29,6 +30,7 @@ const Diet = ({ dietData }) => {
2930
title: dietData['en']?.Seo?.seoTitle || '',
3031
seoTitle: dietData['en']?.Seo?.seoTitle || '',
3132
}}
33+
isLongevityPage
3234
ogTags={OGTags}
3335
createdDate={dietData['en']?.createdAt || ''}
3436
modifiedDate={dietData['en']?.updatedAt || ''}

src/pages/tools/longevity-protocol/habits/lifestyle.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import HabitsLayout from '@layouts/HabitsLayout/HabitsLayout';
44

55
import { getHabitsProtocol } from '@api/longevity/habits-protocol';
66
import SeoGenerator from '@components/SeoGenerator';
7+
import { ogImage } from '@constants/longevity';
78

89
const Lifestyle = ({ habitsData }) => {
910
const OGTags = {
@@ -14,7 +15,7 @@ const Lifestyle = ({ habitsData }) => {
1415
ogImage: {
1516
data: {
1617
attributes: {
17-
url: habitsData['en']?.ogImage?.data?.attributes?.url || '',
18+
url: ogImage,
1819
},
1920
},
2021
},
@@ -29,6 +30,7 @@ const Lifestyle = ({ habitsData }) => {
2930
title: habitsData['en']?.Seo?.pageTitle || '',
3031
seoTitle: habitsData['en']?.Seo?.seoTitle || '',
3132
}}
33+
isLongevityPage
3234
ogTags={OGTags}
3335
createdDate={habitsData['en']?.createdAt || ''}
3436
modifiedDate={habitsData['en']?.updatedAt || ''}

src/pages/tools/longevity-protocol/habits/sleep.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getSleepSupplements } from '@api/longevity/sleep-supplements';
55

66
import SleepLayout from '@layouts/SleepLayout/SleepLayout';
77
import SeoGenerator from '@components/SeoGenerator';
8+
import { ogImage } from '@constants/longevity';
89

910
const Sleep = ({ sleepData, sleepSupplements }) => {
1011
const OGTags = {
@@ -15,7 +16,7 @@ const Sleep = ({ sleepData, sleepSupplements }) => {
1516
ogImage: {
1617
data: {
1718
attributes: {
18-
url: sleepData['en']?.ogImage?.data?.attributes?.url || '',
19+
url: ogImage,
1920
},
2021
},
2122
},
@@ -30,6 +31,7 @@ const Sleep = ({ sleepData, sleepSupplements }) => {
3031
title: sleepData['en']?.Seo?.pageTitle || '',
3132
seoTitle: sleepData['en']?.Seo?.seoTitle || '',
3233
}}
34+
isLongevityPage
3335
ogTags={OGTags}
3436
createdDate={sleepData['en']?.createdAt || ''}
3537
modifiedDate={sleepData['en']?.updatedAt || ''}

src/pages/tools/longevity-protocol/habits/study.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import StudyLayout from '@layouts/StudyLayout';
44

55
import { getStudy } from '@api/longevity/study';
66
import SeoGenerator from '@components/SeoGenerator';
7+
import { ogImage } from '@constants/longevity';
78

89
const Study = ({ studyData }) => {
910
const OGTags = {
@@ -14,7 +15,7 @@ const Study = ({ studyData }) => {
1415
ogImage: {
1516
data: {
1617
attributes: {
17-
url: studyData['en']?.ogImage?.data?.attributes?.url || '',
18+
url: ogImage,
1819
},
1920
},
2021
},
@@ -29,6 +30,7 @@ const Study = ({ studyData }) => {
2930
title: studyData['en']?.Seo?.pageTitle || '',
3031
seoTitle: studyData['en']?.Seo?.seoTitle || '',
3132
}}
33+
isLongevityPage
3234
ogTags={OGTags}
3335
createdDate={studyData['en']?.createdAt || ''}
3436
modifiedDate={studyData['en']?.updatedAt || ''}

src/pages/tools/longevity-protocol/habits/supplements.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SupplementsLayout from '@layouts/Supplements';
44

55
import { getSupplements } from '@api/longevity/supplements';
66
import SeoGenerator from '@components/SeoGenerator';
7+
import { ogImage } from '@constants/longevity';
78

89
const Supplements = ({ supplements }) => {
910
const OGTags = {
@@ -14,7 +15,7 @@ const Supplements = ({ supplements }) => {
1415
ogImage: {
1516
data: {
1617
attributes: {
17-
url: supplements['en']?.ogImage?.data?.attributes?.url || '',
18+
url: ogImage,
1819
},
1920
},
2021
},
@@ -29,6 +30,7 @@ const Supplements = ({ supplements }) => {
2930
title: supplements['en']?.Seo?.pageTitle || '',
3031
seoTitle: supplements['en']?.Seo?.seoTitle || '',
3132
}}
33+
isLongevityPage
3234
ogTags={OGTags}
3335
createdDate={supplements['en']?.createdAt || ''}
3436
modifiedDate={supplements['en']?.updatedAt || ''}

0 commit comments

Comments
 (0)