Skip to content

Commit

Permalink
Add missing seo fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-aac committed Oct 3, 2023
1 parent c09c471 commit e3f35fd
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
16 changes: 16 additions & 0 deletions workspaces/cms-config/src/collections/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions workspaces/cms-config/src/collections/roadmapPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions workspaces/cms-config/src/collections/tutorials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 7 additions & 3 deletions workspaces/website/src/renderer/_default.page.server.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -115,6 +115,10 @@ export async function render(pageContext: PageContextServer) {
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>
${pageSeo?.seoCanonicalUrl ? `
<link rel="canonical" href="${pageSeo?.seoCanonicalUrl}" />
`: ''}
</head>
<body>
<div id="page-view">${stream}</div>
Expand Down
1 change: 1 addition & 0 deletions workspaces/website/src/renderer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface DocumentProps {

export type SeoType = {
seoTitle?: string;
seoCanonicalUrl?: string;
seoDescription?: string;
seoFocusKeywords?: string[];
}
Expand Down

0 comments on commit e3f35fd

Please sign in to comment.