Skip to content

Commit

Permalink
make meta title and description more configurable (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman authored Dec 13, 2024
1 parent 001bc12 commit 765e50e
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 50 deletions.
4 changes: 2 additions & 2 deletions pages/[keyword].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const getStaticProps = async (context) => {

return propsWithGlobalSettings(
{
metaTitle: 'Plural',
metaDescription: page.slug,
metaTitle: page.meta_title,
metaDescription: page.meta_description,
headerVariant: HeaderVariant.min,
footerVariant: FooterVariant.minAlt,
components: page.components ?? [],
Expand Down
1 change: 0 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import 'swiper/css/autoplay'

export type GlobalPageProps = {
metaTitle?: string
metaTitleFull?: string
metaDescription?: string
footerVariant?: FooterVariant
headerVariant?: HeaderVariant
Expand Down
3 changes: 0 additions & 3 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ export const getStaticProps = async () => {

return propsWithGlobalSettings(
{
metaTitle: 'Secure, self-hosted applications in your cloud',
metaDescription:
'Open-source application deployment, faster than ever without sacrificing compliance.',
pageQueryData: page,
footerVariant: FooterVariant.kitchenSink,
errors: combineErrors([error]),
Expand Down
10 changes: 3 additions & 7 deletions src/components/PrimaryPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ReactNode, createContext } from 'react'

import { type GlobalPageProps } from '@pages/_app'
import { PAGE_TITLE_PREFIX, PAGE_TITLE_SUFFIX, ROOT_TITLE } from '@src/consts'
import { PAGE_TITLE_PREFIX } from '@src/consts'
import { NavDataProvider, type NavList } from '@src/contexts/NavDataContext'

import { type GlobalProps } from '../utils/getGlobalProps'
Expand All @@ -25,15 +25,11 @@ export default function PrimaryPage({
pageProps: GlobalPageProps
globalProps: GlobalProps
}) {
const { metaTitle, metaTitleFull, metaDescription } = pageProps || {}
const { metaTitle, metaDescription } = pageProps || {}
const { siteSettings } = globalProps || {}

const headProps = {
title:
metaTitleFull ||
(metaTitle
? `${PAGE_TITLE_PREFIX}${metaTitle}${PAGE_TITLE_SUFFIX}`
: ROOT_TITLE),
title: `${PAGE_TITLE_PREFIX}${metaTitle || siteSettings?.og_title || 'Kubernetes management'}`,
description: metaDescription || siteSettings?.og_description || '',
ogImage: siteSettings.og_image,
}
Expand Down
31 changes: 1 addition & 30 deletions src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
import { type GlobalPageProps } from '@pages/_app'

import { type BasicRepo } from './data/getRepos'
import { type MinStack } from './data/getStacks'

export const ROOT_TITLE =
'Plural | Open-source application deployment, faster than ever without sacrificing compliance.'
export const PAGE_TITLE_PREFIX = 'Plural | '
export const PAGE_TITLE_SUFFIX = ''
export const DISCORD_LINK = 'https://discord.com/invite/bEBAMXV64s'

export const getAppMeta = (repo: BasicRepo): GlobalPageProps => {
const displayName = repo.displayName || repo.name

if (!displayName) return {}

return {
metaTitleFull: `Deploying ${displayName} on Plural`,
metaDescription: `Use Plural to securely deploy and manage ${displayName} on Kubernetes, in your cloud.`,
}
}

export const getStackMeta = (stack: MinStack): GlobalPageProps => {
const displayName = stack.displayName || stack.name

if (!displayName) return {}

return {
metaTitleFull: `Deploying the ${displayName} stack on Plural`,
metaDescription: `Use Plural to securely deploy and manage the ${displayName} stack on Kubernetes, in your cloud.`,
}
}
export const DISCORD_LINK = 'https://discord.com/invite/bEBAMXV64s'

export const REVALIDATE_TIME = 600 // in seconds

Expand Down
3 changes: 2 additions & 1 deletion src/data/getSiteSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const getSiteSettings = (
products?: ProductPageTinyFragment[],
resources?: ResourcePageTinyFragment[]
) => ({
og_description: siteSettings.og_description ?? 'Plural',
og_title: siteSettings.og_title,
og_description: siteSettings.og_description,
og_image: getImageUrl(siteSettings.og_image),
main_nav: {
product: {
Expand Down
35 changes: 29 additions & 6 deletions src/generated/graphqlDirectus.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/graph/directus/customPages.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fragment CustomPage on custom_pages {
id
meta_title
meta_description
slug
components {
custom_component_id {
Expand Down
1 change: 1 addition & 0 deletions src/graph/directus/siteSettings.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fragment SiteSettings on site_settings {
og_title
og_description
og_image {
...ImageFile
Expand Down

0 comments on commit 765e50e

Please sign in to comment.