File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed
(documentation)/docs/[...slug]
components/elements/edit-on-github Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 11import type { Metadata } from 'next/types' ;
22
3- import { EditOnGithub } from '../docs.styles ' ;
3+ import { EditOnGithub } from '@/components/elements/edit-on-github ' ;
44
5- import { PencilSimple } from '@/components/elements/icon' ;
6- import { Link } from '@/components/elements/link' ;
75import { DocumentationLayout } from '@/components/layout/documentation' ;
86import { ROOT_DOCS_DIRECTORY , getAllDocsMeta , getDocBySlug } from '@/lib/mdx/docs' ;
97import { findFile } from '@/lib/mdx/utils/find-file' ;
@@ -52,12 +50,7 @@ export default async function DocsPage({ params }: DocPageProps) {
5250 return (
5351 < DocumentationLayout title = { title } links = { links } >
5452 { Content }
55- < EditOnGithub >
56- < PencilSimple /> Edit this page
57- < Link href = { editUrl } target = "_blank" >
58- on GitHub
59- </ Link >
60- </ EditOnGithub >
53+ < EditOnGithub url = { editUrl } />
6154 </ DocumentationLayout >
6255 ) ;
6356}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { optimizeExcerptToMetaDescription } from '@/lib/utils';
1313import { buildMetadata } from '@/lib/utils/build-metadata' ;
1414import { Newsletter } from '@/components/modules/newsletter' ;
1515import { NEWSLETTER_URLS } from '@/components/modules/newsletter/newsletter.values' ;
16+ import { EditOnGithub } from '@/components/elements/edit-on-github' ;
1617
1718type BlogPostPageProps = {
1819 params : { slug : string } ;
@@ -54,10 +55,13 @@ export async function generateStaticParams() {
5455 } ) ) ;
5556}
5657
58+ const githubBlogUrl = 'https://github.com/httptoolkit/httptoolkit-website/blob/main/src/content/posts' ;
59+
5760export default async function BlogPostPage ( { params } : BlogPostPageProps ) {
5861 const { slug } = params ;
5962 const post = await getPostBySlug ( slug ) ;
6063 const postNavigation = await getBlogTitlesBySlug ( slug ) ;
64+ const editUrl = `${ githubBlogUrl } /${ slug } .mdx` ;
6165
6266 return (
6367 < >
@@ -69,9 +73,10 @@ export default async function BlogPostPage({ params }: BlogPostPageProps) {
6973 $bgVariant = "darkGrey"
7074 links = { [ postNavigation ] }
7175 parsedContent = { post . content }
72- additionalContent = {
76+ additionalContent = { < >
77+ < EditOnGithub url = { editUrl } />
7378 < SocialPostShare postTitle = { post . title } postUrl = { post . slug } socialLinks = { post . socialLinks } />
74- }
79+ </ > }
7580 />
7681
7782 < Container >
Original file line number Diff line number Diff line change 22
33import { styled } from '@/styles' ;
44
5- export const EditOnGithub = styled . em `
5+ import { PencilSimple } from '@/components/elements/icon' ;
6+ import { Link } from '@/components/elements/link' ;
7+
8+ const EditText = styled . em `
69 margin-top: 20px;
710 display: flex;
811 align-items: center;
@@ -21,3 +24,10 @@ export const EditOnGithub = styled.em`
2124 }
2225 }
2326` ;
27+
28+ export const EditOnGithub = ( props : { url : string } ) => < EditText >
29+ < PencilSimple /> Edit this page
30+ < Link href = { props . url } target = "_blank" >
31+ on GitHub
32+ </ Link >
33+ </ EditText >
You can’t perform that action at this time.
0 commit comments