Merge pull request #115 from learnhouse/swve/eng-110-seo-dynamic-seo-tags

Add seo tags, opengraph & robots directives
This commit is contained in:
Badr B 2023-09-19 20:06:12 +02:00 committed by GitHub
commit 16cd5e4cf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 175 additions and 74 deletions

View file

@ -23,11 +23,25 @@ export async function generateMetadata(
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
const col = await getCollectionByIdWithAuthHeader(params.collectionid, access_token ? access_token : null, { revalidate: 0, tags: ['collections'] });
// SEO
return {
title: `Collection : ${col.name}${org.name}`,
description: `${col.description} `,
robots: {
index: true,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
}
},
openGraph: {
title: `Collection : ${col.name}${org.name}`,
description: `${col.description} `,
type: 'website',
},
};
}

View file

@ -22,9 +22,26 @@ export async function generateMetadata(
const cookieStore = cookies();
// Get Org context information
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
// SEO
return {
title: `Collections — ${org.name}`,
description: `Collections of courses from ${org.name}`,
robots: {
index: true,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
}
},
openGraph: {
title: `Collections — ${org.name}`,
description: `Collections of courses from ${org.name}`,
type: 'website',
},
};
}

View file

@ -23,9 +23,28 @@ export async function generateMetadata(
const course_meta = await getCourseMetadataWithAuthHeader(params.courseid, { revalidate: 0, tags: ['courses'] }, access_token ? access_token : null)
const activity = await getActivityWithAuthHeader(params.activityid, { revalidate: 0, tags: ['activities'] }, access_token ? access_token : null)
// SEO
return {
title: activity.name + `${course_meta.course.name} Course`,
description: course_meta.course.mini_description,
keywords: course_meta.course.learnings,
robots: {
index: true,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
}
},
openGraph: {
title: activity.name + `${course_meta.course.name} Course`,
description: course_meta.course.mini_description,
type: activity.type === 'video' ? 'video.other' : 'article',
publishedTime: course_meta.course.creationDate,
tags: course_meta.course.learnings,
},
};
}

View file

@ -17,19 +17,37 @@ export async function generateMetadata(
const cookieStore = cookies();
const access_token = await getAccessTokenFromRefreshTokenCookie(cookieStore)
// Get Org context information
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
const course_meta = await getCourseMetadataWithAuthHeader(params.courseid, { revalidate: 0, tags: ['courses'] }, access_token ? access_token : null)
// SEO
return {
title: course_meta.course.name + `${org.name}`,
description: course_meta.course.mini_description,
keywords: course_meta.course.learnings,
robots: {
index: true,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
}
},
openGraph: {
title: course_meta.course.name + `${org.name}`,
description: course_meta.course.mini_description,
type: 'article',
publishedTime: course_meta.course.creationDate,
tags: course_meta.course.learnings,
},
};
}
const CoursePage = async (params: any) => {
const cookieStore = cookies();
const courseid = params.params.courseid

View file

@ -18,9 +18,27 @@ export async function generateMetadata(
// Get Org context information
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
// SEO
return {
title: "Courses — " + org.name,
description: org.description,
keywords: `${org.name}, ${org.description}, courses, learning, education, online learning, edu, online courses, ${org.name} courses`,
robots: {
index: true,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
}
},
openGraph: {
title: "Courses — " + org.name,
description: org.description,
type: 'website',
},
};
}

View file

@ -22,13 +22,28 @@ type MetadataProps = {
export async function generateMetadata(
{ params }: MetadataProps,
): Promise<Metadata> {
// Get Org context information
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
// SEO
return {
title: `Home — ${org.name}`,
description: org.description,
robots: {
index: true,
follow: true,
nocache: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
}
},
openGraph: {
title: `Home — ${org.name}`,
description: org.description,
type: 'website',
},
};
}

122
front/package-lock.json generated
View file

@ -26,7 +26,7 @@
"formik": "^2.2.9",
"framer-motion": "^10.16.1",
"lucide-react": "^0.268.0",
"next": "^13.4.19",
"next": "^13.5.1",
"re-resizable": "^6.9.9",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
@ -54,7 +54,7 @@
"@types/uuid": "^9.0.0",
"autoprefixer": "^10.4.14",
"eslint": "^8.43.0",
"eslint-config-next": "^13.0.6",
"eslint-config-next": "^13.5.1",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2",
"typescript": "5.1.3"
@ -2262,14 +2262,14 @@
}
},
"node_modules/@next/env": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.19.tgz",
"integrity": "sha512-FsAT5x0jF2kkhNkKkukhsyYOrRqtSxrEhfliniIq0bwWbuXLgyt3Gv0Ml+b91XwjwArmuP7NxCiGd++GGKdNMQ=="
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.1.tgz",
"integrity": "sha512-CIMWiOTyflFn/GFx33iYXkgLSQsMQZV4jB91qaj/TfxGaGOXxn8C1j72TaUSPIyN7ziS/AYG46kGmnvuk1oOpg=="
},
"node_modules/@next/eslint-plugin-next": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.4.19.tgz",
"integrity": "sha512-N/O+zGb6wZQdwu6atMZHbR7T9Np5SUFUjZqCbj0sXm+MwQO35M8TazVB4otm87GkXYs2l6OPwARd3/PUWhZBVQ==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.5.1.tgz",
"integrity": "sha512-LBlI3iQvlzRE7Y6AfIyHKuM4T6REGmFgweN2tBqEUVEfgxERBLOutV2xckXEp3Y3VbfJBBXKZNfDzs20gHimSg==",
"dev": true,
"dependencies": {
"glob": "7.1.7"
@ -2296,9 +2296,9 @@
}
},
"node_modules/@next/swc-darwin-arm64": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.19.tgz",
"integrity": "sha512-vv1qrjXeGbuF2mOkhkdxMDtv9np7W4mcBtaDnHU+yJG+bBwa6rYsYSCI/9Xm5+TuF5SbZbrWO6G1NfTh1TMjvQ==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.1.tgz",
"integrity": "sha512-Bcd0VFrLHZnMmJy6LqV1CydZ7lYaBao8YBEdQUVzV8Ypn/l5s//j5ffjfvMzpEQ4mzlAj3fIY+Bmd9NxpWhACw==",
"cpu": [
"arm64"
],
@ -2311,9 +2311,9 @@
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.19.tgz",
"integrity": "sha512-jyzO6wwYhx6F+7gD8ddZfuqO4TtpJdw3wyOduR4fxTUCm3aLw7YmHGYNjS0xRSYGAkLpBkH1E0RcelyId6lNsw==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.1.tgz",
"integrity": "sha512-uvTZrZa4D0bdWa1jJ7X1tBGIxzpqSnw/ATxWvoRO9CVBvXSx87JyuISY+BWsfLFF59IRodESdeZwkWM2l6+Kjg==",
"cpu": [
"x64"
],
@ -2326,9 +2326,9 @@
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.19.tgz",
"integrity": "sha512-vdlnIlaAEh6H+G6HrKZB9c2zJKnpPVKnA6LBwjwT2BTjxI7e0Hx30+FoWCgi50e+YO49p6oPOtesP9mXDRiiUg==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.1.tgz",
"integrity": "sha512-/52ThlqdORPQt3+AlMoO+omicdYyUEDeRDGPAj86ULpV4dg+/GCFCKAmFWT0Q4zChFwsAoZUECLcKbRdcc0SNg==",
"cpu": [
"arm64"
],
@ -2341,9 +2341,9 @@
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.19.tgz",
"integrity": "sha512-aU0HkH2XPgxqrbNRBFb3si9Ahu/CpaR5RPmN2s9GiM9qJCiBBlZtRTiEca+DC+xRPyCThTtWYgxjWHgU7ZkyvA==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.1.tgz",
"integrity": "sha512-L4qNXSOHeu1hEAeeNsBgIYVnvm0gg9fj2O2Yx/qawgQEGuFBfcKqlmIE/Vp8z6gwlppxz5d7v6pmHs1NB6R37w==",
"cpu": [
"arm64"
],
@ -2356,9 +2356,9 @@
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.19.tgz",
"integrity": "sha512-htwOEagMa/CXNykFFeAHHvMJeqZfNQEoQvHfsA4wgg5QqGNqD5soeCer4oGlCol6NGUxknrQO6VEustcv+Md+g==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.1.tgz",
"integrity": "sha512-QVvMrlrFFYvLtABk092kcZ5Mzlmsk2+SV3xYuAu8sbTuIoh0U2+HGNhVklmuYCuM3DAAxdiMQTNlRQmNH11udw==",
"cpu": [
"x64"
],
@ -2371,9 +2371,9 @@
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.19.tgz",
"integrity": "sha512-4Gj4vvtbK1JH8ApWTT214b3GwUh9EKKQjY41hH/t+u55Knxi/0wesMzwQRhppK6Ddalhu0TEttbiJ+wRcoEj5Q==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.1.tgz",
"integrity": "sha512-bBnr+XuWc28r9e8gQ35XBtyi5KLHLhTbEvrSgcWna8atI48sNggjIK8IyiEBO3KIrcUVXYkldAzGXPEYMnKt1g==",
"cpu": [
"x64"
],
@ -2386,9 +2386,9 @@
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.19.tgz",
"integrity": "sha512-bUfDevQK4NsIAHXs3/JNgnvEY+LRyneDN788W2NYiRIIzmILjba7LaQTfihuFawZDhRtkYCv3JDC3B4TwnmRJw==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.1.tgz",
"integrity": "sha512-EQGeE4S5c9v06jje9gr4UlxqUEA+zrsgPi6kg9VwR+dQHirzbnVJISF69UfKVkmLntknZJJI9XpWPB6q0Z7mTg==",
"cpu": [
"arm64"
],
@ -2401,9 +2401,9 @@
}
},
"node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.19.tgz",
"integrity": "sha512-Y5kikILFAr81LYIFaw6j/NrOtmiM4Sf3GtOc0pn50ez2GCkr+oejYuKGcwAwq3jiTKuzF6OF4iT2INPoxRycEA==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.1.tgz",
"integrity": "sha512-1y31Q6awzofVjmbTLtRl92OX3s+W0ZfO8AP8fTnITcIo9a6ATDc/eqa08fd6tSpFu6IFpxOBbdevOjwYTGx/AQ==",
"cpu": [
"ia32"
],
@ -2416,9 +2416,9 @@
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.19.tgz",
"integrity": "sha512-YzA78jBDXMYiINdPdJJwGgPNT3YqBNNGhsthsDoWHL9p24tEJn9ViQf/ZqTbwSpX/RrkPupLfuuTH2sf73JBAw==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.1.tgz",
"integrity": "sha512-+9XBQizy7X/GuwNegq+5QkkxAPV7SBsIwapVRQd9WSvvU20YO23B3bZUpevdabi4fsd25y9RJDDncljy/V54ww==",
"cpu": [
"x64"
],
@ -3447,9 +3447,9 @@
}
},
"node_modules/@swc/helpers": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz",
"integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==",
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz",
"integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==",
"dependencies": {
"tslib": "^2.4.0"
}
@ -5183,19 +5183,19 @@
}
},
"node_modules/eslint-config-next": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.4.19.tgz",
"integrity": "sha512-WE8367sqMnjhWHvR5OivmfwENRQ1ixfNE9hZwQqNCsd+iM3KnuMc1V8Pt6ytgjxjf23D+xbesADv9x3xaKfT3g==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.5.1.tgz",
"integrity": "sha512-+8xIIWtD+iFwHfXgmXRGn05BuNIu/RAGcz6kI4wsJTPrE/1WtWKv2o0l+GbQ6wRaC+cbBV8+QnFAOf18aJiWrg==",
"dev": true,
"dependencies": {
"@next/eslint-plugin-next": "13.4.19",
"@rushstack/eslint-patch": "^1.1.3",
"@next/eslint-plugin-next": "13.5.1",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.31.7",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.5.0 || 5.0.0-canary-7118f5dd7-20230705"
},
"peerDependencies": {
@ -7003,12 +7003,12 @@
"dev": true
},
"node_modules/next": {
"version": "13.4.19",
"resolved": "https://registry.npmjs.org/next/-/next-13.4.19.tgz",
"integrity": "sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/next/-/next-13.5.1.tgz",
"integrity": "sha512-GIudNR7ggGUZoIL79mSZcxbXK9f5pwAIPZxEM8+j2yLqv5RODg4TkmUlaKSYVqE1bPQueamXSqdC3j7axiTSEg==",
"dependencies": {
"@next/env": "13.4.19",
"@swc/helpers": "0.5.1",
"@next/env": "13.5.1",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
@ -7020,18 +7020,18 @@
"next": "dist/bin/next"
},
"engines": {
"node": ">=16.8.0"
"node": ">=16.14.0"
},
"optionalDependencies": {
"@next/swc-darwin-arm64": "13.4.19",
"@next/swc-darwin-x64": "13.4.19",
"@next/swc-linux-arm64-gnu": "13.4.19",
"@next/swc-linux-arm64-musl": "13.4.19",
"@next/swc-linux-x64-gnu": "13.4.19",
"@next/swc-linux-x64-musl": "13.4.19",
"@next/swc-win32-arm64-msvc": "13.4.19",
"@next/swc-win32-ia32-msvc": "13.4.19",
"@next/swc-win32-x64-msvc": "13.4.19"
"@next/swc-darwin-arm64": "13.5.1",
"@next/swc-darwin-x64": "13.5.1",
"@next/swc-linux-arm64-gnu": "13.5.1",
"@next/swc-linux-arm64-musl": "13.5.1",
"@next/swc-linux-x64-gnu": "13.5.1",
"@next/swc-linux-x64-musl": "13.5.1",
"@next/swc-win32-arm64-msvc": "13.5.1",
"@next/swc-win32-ia32-msvc": "13.5.1",
"@next/swc-win32-x64-msvc": "13.5.1"
},
"peerDependencies": {
"@opentelemetry/api": "^1.1.0",

View file

@ -27,7 +27,7 @@
"formik": "^2.2.9",
"framer-motion": "^10.16.1",
"lucide-react": "^0.268.0",
"next": "^13.4.19",
"next": "^13.5.1",
"re-resizable": "^6.9.9",
"react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1",
@ -55,7 +55,7 @@
"@types/uuid": "^9.0.0",
"autoprefixer": "^10.4.14",
"eslint": "^8.43.0",
"eslint-config-next": "^13.0.6",
"eslint-config-next": "^13.5.1",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2",
"typescript": "5.1.3"

View file

@ -1,7 +1,7 @@
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { NextRouter } from "next/router";
export const denyAccessToUser = (error : any, router: AppRouterInstance) => {
export const denyAccessToUser = (error: any, router: AppRouterInstance) => {
if (error.status === 401) {
router.push("/login");
}
@ -10,5 +10,4 @@ export const denyAccessToUser = (error : any, router: AppRouterInstance) => {
router.push("/login");
// TODO : add a message to the user to tell him he is not allowed to access this page, route to /error
}
}
};

View file

@ -1,4 +1,5 @@
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { denyAccessToUser } from "../react/middlewares/views";
import { getUriWithOrg, LEARNHOUSE_DOMAIN, LEARNHOUSE_HTTP_PROTOCOL } from "@services/config/config";