Skip to content

Commit

Permalink
Add project page meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulrhmnGhanem committed Jul 3, 2023
1 parent 3799789 commit 74aa7d2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = async phase => {
// we use nginx to compress so we turn off next.js gzip compression
compress: false,
publicRuntimeConfig: {
KITSPACE_DOMAIN: process.env.KITSPACE_DOMAIN,
KITSPACE_GITEA_URL: process.env.KITSPACE_GITEA_URL,
KITSPACE_ASSET_URL: process.env.KITSPACE_ASSET_URL,
KITSPACE_MEILISEARCH_URL: process.env.KITSPACE_MEILISEARCH_URL,
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Head.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from 'react'
import NextHead from 'next/head'
import { string } from 'prop-types'

const Head = ({ title, description, url, ogImage }) => (
const Head = ({ title, ogDescription, url, ogImage }) => (
<NextHead>
<meta charSet="UTF-8" />
<title>{title}</title>
<meta content={description} name="description" />
<meta content={ogDescription} name="description" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content={url} property="og:url" />
<meta content={title} property="og:title" />
<meta content={description} property="og:description" />
<meta content={ogDescription} property="og:description" />
<meta content={url} name="twitter:site" />
<meta content="summary_large_image" name="twitter:card" />
<meta content={ogImage} name="twitter:image" />
Expand Down Expand Up @@ -54,7 +54,7 @@ const Head = ({ title, description, url, ogImage }) => (
)

Head.propTypes = {
description: string,
ogDescription: string,
ogImage: string,
title: string,
url: string,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Page/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Page = ({ title, initialQuery, contentFullSize, children }) => {
}

Page.propTypes = {
title: string.isRequired,
title: string,
initialQuery: string,
contentFullSize: bool,
children: node.isRequired,
Expand Down
17 changes: 14 additions & 3 deletions frontend/src/components/SharedProjectPage/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React, { useEffect, useState } from 'react'
import getConfig from 'next/config'
import { useRouter } from 'next/router'
import { Loader, Message } from 'semantic-ui-react'
import { bool, object, string } from 'prop-types'

import Page from '@components/Page'
import Head from '@components/Head'
import { useMigrationStatus } from '@hooks/Gitea'
import PageElements from './elements'
import useProcessingStatus from '@hooks/useProcessingStatus'
import { bool, object, string } from 'prop-types'
import PageElements from './elements'

const { KITSPACE_DOMAIN } = getConfig().publicRuntimeConfig

const SharedProjectPage = props => {
const { reload } = useRouter()
Expand Down Expand Up @@ -72,7 +76,13 @@ const SharedProjectPage = props => {
}

return (
<Page title={title}>
<Page>
<Head
description={props.ogDescription}
ogImage={`${props.rootAssetPath}/${props.projectName}/images/top-with-background.png'`}
title={title}
url={`https://${KITSPACE_DOMAIN}/${props.username}/${props.repoName}`}
/>
{props.isSynced && props.hasUploadPermission ? (
<Message color="yellow" data-cy="sync-msg">
<Message.Header>A synced repository!</Message.Header>
Expand All @@ -96,6 +106,7 @@ const SharedProjectPage = props => {
SharedProjectPage.propTypes = {
rootAssetPath: string.isRequired,
description: string.isRequired,
ogDescription: string.isRequired,
repoName: string.isRequired,
projectName: string.isRequired,
projectFullname: string.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/[user]/[repo]/[project]/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ MultiProjectPage.getInitialProps = async ({ query, req = null, res = null }) =>
username,
projectName,
repoName,
isNew: query.create === 'true',
gerberInfoExists,
bomInfoExists,
readmeExists: readme !== null,
kitspaceYAMLExists,
boardShowcaseAssetsExist: gerberInfoExists,
finishedProcessing,
description: kitspaceYAML.summary,
ogDescription: kitspaceYAML.summary,
description: kitspaceYAML.rendered_summary,
originalUrl: repo?.original_url,
}
}
Expand Down
3 changes: 2 additions & 1 deletion processor/src/tasks/writeKitspaceYaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ async function renderKitspaceYamlSummaries(kitspaceYamlArray: Array<KitspaceYaml
return Promise.all(
kitspaceYamlArray.map(async yml => ({
...yml,
summary: await renderSummary(yml.summary),
summary: yml.summary,
rendered_summary: await renderSummary(yml.summary),
})),
)
}
Expand Down

0 comments on commit 74aa7d2

Please sign in to comment.