@@ -12,11 +12,14 @@ import { materialOceanic } from "react-syntax-highlighter/dist/cjs/styles/prism"
1212import Link from "next/link" ;
1313import Head from "next/head" ;
1414import { useRouter } from "next/router" ;
15+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
16+ import { faPen } from "@fortawesome/free-solid-svg-icons" ;
1517
1618const ARTICLES_PATH = path . join ( process . cwd ( ) , "articles" ) ;
1719
1820interface Props {
1921 content : string ;
22+ title : string ;
2023}
2124
2225const Container = styled . div `
@@ -32,6 +35,7 @@ const Container = styled.div`
3235` ;
3336
3437const ReactMarkdownContainer = styled . div `
38+ position: relative;
3539 display: block;
3640 overflow: hidden;
3741 margin-bottom: 30em;
@@ -113,6 +117,16 @@ const SidebarHolder = styled.div`
113117 }
114118` ;
115119
120+ const Edit = styled . a `
121+ text-decoration: none;
122+ color: #186eee;
123+ position: absolute;
124+ padding: 0 !important;
125+ top: 0.8em;
126+ right: 0.8em;
127+ cursor: pointer;
128+ ` ;
129+
116130export default function DocPage ( props : Props ) {
117131 const [ showMobileMenu , setShowMobileMenu ] = useState ( false ) ;
118132 return (
@@ -131,6 +145,14 @@ export default function DocPage(props: Props) {
131145 < SideBar />
132146 </ SidebarHolder >
133147 < ReactMarkdownContainer >
148+ < Link
149+ passHref
150+ href = { `https://github.com/CodeStix/typed-react-form-docs/tree/main/articles/${ props . title } .md` }
151+ >
152+ < Edit >
153+ Edit < FontAwesomeIcon icon = { faPen } />
154+ </ Edit >
155+ </ Link >
134156 < ReactMarkdown
135157 renderers = { {
136158 link : ( { children, href } ) => {
@@ -165,6 +187,7 @@ export const getStaticProps: GetStaticProps<Props> = async function (props) {
165187 let file = path . join ( ARTICLES_PATH , title + ".md" ) ;
166188 return {
167189 props : {
190+ title,
168191 content : await fs . readFile ( file , "utf-8" ) ,
169192 } ,
170193 } ;
0 commit comments