@@ -12,11 +12,14 @@ import { materialOceanic } from "react-syntax-highlighter/dist/cjs/styles/prism"
12
12
import Link from "next/link" ;
13
13
import Head from "next/head" ;
14
14
import { useRouter } from "next/router" ;
15
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
16
+ import { faPen } from "@fortawesome/free-solid-svg-icons" ;
15
17
16
18
const ARTICLES_PATH = path . join ( process . cwd ( ) , "articles" ) ;
17
19
18
20
interface Props {
19
21
content : string ;
22
+ title : string ;
20
23
}
21
24
22
25
const Container = styled . div `
@@ -32,6 +35,7 @@ const Container = styled.div`
32
35
` ;
33
36
34
37
const ReactMarkdownContainer = styled . div `
38
+ position: relative;
35
39
display: block;
36
40
overflow: hidden;
37
41
margin-bottom: 30em;
@@ -113,6 +117,16 @@ const SidebarHolder = styled.div`
113
117
}
114
118
` ;
115
119
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
+
116
130
export default function DocPage ( props : Props ) {
117
131
const [ showMobileMenu , setShowMobileMenu ] = useState ( false ) ;
118
132
return (
@@ -131,6 +145,14 @@ export default function DocPage(props: Props) {
131
145
< SideBar />
132
146
</ SidebarHolder >
133
147
< 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 >
134
156
< ReactMarkdown
135
157
renderers = { {
136
158
link : ( { children, href } ) => {
@@ -165,6 +187,7 @@ export const getStaticProps: GetStaticProps<Props> = async function (props) {
165
187
let file = path . join ( ARTICLES_PATH , title + ".md" ) ;
166
188
return {
167
189
props : {
190
+ title,
168
191
content : await fs . readFile ( file , "utf-8" ) ,
169
192
} ,
170
193
} ;
0 commit comments