From e3f35fd6f6faf7360853c6f7ebc05afa4e9aedbe Mon Sep 17 00:00:00 2001 From: nuno-aac Date: Tue, 3 Oct 2023 15:43:16 +0100 Subject: [PATCH] Add missing seo fields --- .../cms-config/src/collections/posts.ts | 16 +++++++++++++ .../src/collections/roadmapPosts.ts | 23 +++++++++++++++++++ .../cms-config/src/collections/tutorials.ts | 23 +++++++++++++++++++ .../src/renderer/_default.page.server.tsx | 10 +++++--- workspaces/website/src/renderer/types.ts | 1 + 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/workspaces/cms-config/src/collections/posts.ts b/workspaces/cms-config/src/collections/posts.ts index a7e3ad308f..2f4db752fb 100644 --- a/workspaces/cms-config/src/collections/posts.ts +++ b/workspaces/cms-config/src/collections/posts.ts @@ -133,6 +133,22 @@ export const postsCollectionConfig = { label: "Short Description", widget: "text", }, + { + required: false, + name: "seoFocusKeywords", + label: "Seo focus keywords", + hint: "Enter the focus keywords separated by commas", + widget: 'list', + crowdin: true, + }, + { + required: false, + name: "seoCanonicalUrl", + label: "Seo Canonical url", + hint: "If the article was lifted from somewhere else, you can link it here", + widget: 'string', + crowdin: true, + }, { name: "blocks", label: "Blocks", diff --git a/workspaces/cms-config/src/collections/roadmapPosts.ts b/workspaces/cms-config/src/collections/roadmapPosts.ts index e75f1a6cfa..fcc985b9c6 100644 --- a/workspaces/cms-config/src/collections/roadmapPosts.ts +++ b/workspaces/cms-config/src/collections/roadmapPosts.ts @@ -46,6 +46,29 @@ export const roadmapPostsCollectionConfig = { widget: "string", crowdin: true, }, + { + required: false, + name: "seoTitle", + label: "Seo title", + hint: "If empty the title field will be used", + widget: "string", + crowdin: true, + }, + { + required: false, + name: "seoDescription", + label: "Seo description", + widget: "string", + crowdin: true, + }, + { + required: false, + name: "seoFocusKeywords", + label: "Seo focus keywords", + hint: "Enter the focus keywords separated by commas", + widget: 'list', + crowdin: true, + }, { name: "availability", label: "Availability", diff --git a/workspaces/cms-config/src/collections/tutorials.ts b/workspaces/cms-config/src/collections/tutorials.ts index 460cb634ee..3170a98895 100644 --- a/workspaces/cms-config/src/collections/tutorials.ts +++ b/workspaces/cms-config/src/collections/tutorials.ts @@ -54,6 +54,29 @@ export const tutorialsCollectionConfig = { widget: "string", crowdin: true }, + { + required: false, + name: "seoTitle", + label: "Seo title", + hint: "If empty the title field will be used", + widget: "string", + crowdin: true, + }, + { + required: false, + name: "seoDescription", + label: "Seo description", + widget: "string", + crowdin: true, + }, + { + required: false, + name: "seoFocusKeywords", + label: "Seo focus keywords", + hint: "Enter the focus keywords separated by commas", + widget: 'list', + crowdin: true, + }, { name: "authors", label: "Authors", diff --git a/workspaces/website/src/renderer/_default.page.server.tsx b/workspaces/website/src/renderer/_default.page.server.tsx index fb67c75e71..99fb2b9b47 100644 --- a/workspaces/website/src/renderer/_default.page.server.tsx +++ b/workspaces/website/src/renderer/_default.page.server.tsx @@ -1,6 +1,6 @@ import { renderToStream } from "react-streaming/server"; import { escapeInject } from "vite-plugin-ssr/server"; -import { PageContextServer, SeoType } from "./types"; +import { DocumentProps, PageContextServer, SeoType } from "./types"; import { PageShell } from "./PageShell"; import { getDefaultPageContext } from "./helpers"; import type { InjectFilterEntry } from "vite-plugin-ssr/types"; @@ -41,9 +41,9 @@ export async function render(pageContext: PageContextServer) { }); const GOOGLE_TAG_ID = "G-WY42TERK5P"; - const pageSeo = pageProps?.data as SeoType + const pageSeo = (pageProps?.data ?? pageProps?.roadmapPost ?? pageProps?.tutorial) as SeoType const documentProps = - pageContext.documentProps ?? pageContext.exports.documentProps; + pageContext.documentProps ?? pageContext.exports.documentProps const title = documentProps?.title ?? pageSeo?.seoTitle ? `${documentProps?.title ?? pageSeo?.seoTitle} - Starknet` @@ -115,6 +115,10 @@ export async function render(pageContext: PageContextServer) { a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); + + ${pageSeo?.seoCanonicalUrl ? ` + + `: ''}
${stream}
diff --git a/workspaces/website/src/renderer/types.ts b/workspaces/website/src/renderer/types.ts index c92ec4d1cf..acb711b577 100644 --- a/workspaces/website/src/renderer/types.ts +++ b/workspaces/website/src/renderer/types.ts @@ -25,6 +25,7 @@ export interface DocumentProps { export type SeoType = { seoTitle?: string; + seoCanonicalUrl?: string; seoDescription?: string; seoFocusKeywords?: string[]; }