Skip to content

Commit

Permalink
Update OG image for docs with new brand guidelines (#936)
Browse files Browse the repository at this point in the history
Update the OG image with the new brand guidelines
  • Loading branch information
MaedahBatool authored Jan 29, 2025
1 parent 1e755c3 commit 1082cb9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 62 deletions.
Binary file added public/sourcegraph-og-nw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 14 additions & 13 deletions src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import { Breadcrumbs } from '@/components/Breadcrumbs';
import {Breadcrumbs} from '@/components/Breadcrumbs';
import MdxComponents from '@/components/MdxComponents';
import { PrevNextLinks } from '@/components/PrevNextLinks';
import { Prose } from '@/components/Prose';
import { TableOfContents } from '@/components/Toc';
import { allPosts } from 'contentlayer/generated';
import { getMDXComponent } from 'next-contentlayer/hooks';
import { notFound } from 'next/navigation';
import {PrevNextLinks} from '@/components/PrevNextLinks';
import {Prose} from '@/components/Prose';
import {TableOfContents} from '@/components/Toc';
import {allPosts} from 'contentlayer/generated';
import {getMDXComponent} from 'next-contentlayer/hooks';
import {notFound} from 'next/navigation';

export const maxDuration = 300;

export const generateStaticParams = async () => {
return allPosts.map(post => ({
params: { slug: post._raw.flattenedPath.split('/') }
params: {slug: post._raw.flattenedPath.split('/')}
}));
};

export const generateMetadata = ({ params }: Props) => {
export const generateMetadata = ({params}: Props) => {
const path = params.slug.join('/');
const post = allPosts.find(post => post._raw.flattenedPath === path);
if (post && post.headings && post.headings.length > 0) {

return {
return {
title: post.headings[0].title,
openGraph: {
images: [{url: 'https://sourcegraph.com/docs/sourcegraph-docs-c.png'}]
images: [
{url: 'https://sourcegraph.com/docs/sourcegraph-og-nw.png'}
]
}
};
}
Expand All @@ -35,7 +36,7 @@ interface Props {
};
}

const PostLayout = ({ params }: Props) => {
const PostLayout = ({params}: Props) => {
const path = params.slug.join('/');
const post = allPosts.find(post => post._raw.flattenedPath === path);
if (!post) return notFound();
Expand Down
79 changes: 39 additions & 40 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Providers } from '@/app/providers';
import { Layout } from '@/components/Layout';
import { GoogleAnalytics } from '@next/third-parties/google';
import {Providers} from '@/app/providers';
import {Layout} from '@/components/Layout';
import {GoogleAnalytics} from '@next/third-parties/google';
import clsx from 'clsx';
import config from 'docs.config';
import { type Metadata } from 'next';
import { Inter } from 'next/font/google';
import {type Metadata} from 'next';
import {Inter} from 'next/font/google';
import localFont from 'next/font/local';
import Chatbot from '@/components/ChatBot';

import '@langbase/components/styles'
import '@/styles/tailwind.css';
import '@langbase/components/styles';

const inter = Inter({
subsets: ['latin'],
Expand All @@ -30,60 +29,60 @@ export const metadata: Metadata = {
template: '%s - Sourcegraph docs',
default: 'Sourcegraph docs'
},
description: 'Documentation for Sourcegraph, the code intelligence platform.',
description:
'Documentation for Sourcegraph, the code intelligence platform.',
other: {
"docsearch:language": "en",
"docsearch:version": `v${config.DOCS_LATEST_VERSION}`
'docsearch:language': 'en',
'docsearch:version': `v${config.DOCS_LATEST_VERSION}`
},
alternates: {
canonical: '/docs'
},
openGraph: {
images: [{ url: 'https://sourcegraph.com/docs/sourcegraph-docs-c.png' }]
images: [{url: 'https://sourcegraph.com/docs/sourcegraph-og-nw.png'}]
}
};


// PolySans Variable Font
const polySansVariable = localFont({
src: [
{
path: '../fonts/PolySans-Neutral.woff',
style: 'normal',
},
{
path: '../fonts/PolySans-NeutralItalic.woff',
style: 'italic',
}
],
variable: '--font-polysans'
src: [
{
path: '../fonts/PolySans-Neutral.woff',
style: 'normal'
},
{
path: '../fonts/PolySans-NeutralItalic.woff',
style: 'italic'
}
],
variable: '--font-polysans'
});

// PolySans Mono Font
const polySansMono = localFont({
src: [
{
path: '../fonts/PolySans-NeutralMono.woff',
style: 'normal',
},
{
path: '../fonts/PolySans-SlimMono.woff',
style: 'normal',
}
],
variable: '--font-polysans-mono'
src: [
{
path: '../fonts/PolySans-NeutralMono.woff',
style: 'normal'
},
{
path: '../fonts/PolySans-SlimMono.woff',
style: 'normal'
}
],
variable: '--font-polysans-mono'
});

export default function RootLayout({ children }: { children: React.ReactNode }) {
export default function RootLayout({children}: {children: React.ReactNode}) {
return (
<html
lang="en"
style={{ colorScheme: 'dark' }}
style={{colorScheme: 'dark'}}
className={clsx(
'h-full antialiased',
polySansVariable.variable,
polySansMono.variable
)}
'h-full antialiased',
polySansVariable.variable,
polySansMono.variable
)}
suppressHydrationWarning
>
<head>
Expand Down
19 changes: 10 additions & 9 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import MdxComponents from '@/components/MdxComponents';
import { Prose } from '@/components/Prose';
import { GoogleAnalytics } from '@next/third-parties/google';
import { allPosts } from 'contentlayer/generated';
import { getMDXComponent } from 'next-contentlayer/hooks';
import { notFound } from 'next/navigation';
import {Prose} from '@/components/Prose';
import {GoogleAnalytics} from '@next/third-parties/google';
import {allPosts} from 'contentlayer/generated';
import {getMDXComponent} from 'next-contentlayer/hooks';
import {notFound} from 'next/navigation';

export const generateMetadata = () => {
return {
openGraph: {
images: [{url: 'https://sourcegraph.com/docs/sourcegraph-docs-c.png'}]
images: [
{url: 'https://sourcegraph.com/docs/sourcegraph-og-nw.png'}
]
}
}
}
};
};

const PostLayout = () => {
const post = allPosts.find(post => post._raw.flattenedPath === '');
Expand All @@ -29,7 +31,6 @@ const PostLayout = () => {
</div>
<GoogleAnalytics gaId="GTM-TB4NLS7" />
</>

);
};

Expand Down

0 comments on commit 1082cb9

Please sign in to comment.