Skip to content

Commit 422804c

Browse files
committed
Edit button
1 parent aa125fd commit 422804c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pages/docs/[doc].tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import { materialOceanic } from "react-syntax-highlighter/dist/cjs/styles/prism"
1212
import Link from "next/link";
1313
import Head from "next/head";
1414
import { useRouter } from "next/router";
15+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
16+
import { faPen } from "@fortawesome/free-solid-svg-icons";
1517

1618
const ARTICLES_PATH = path.join(process.cwd(), "articles");
1719

1820
interface Props {
1921
content: string;
22+
title: string;
2023
}
2124

2225
const Container = styled.div`
@@ -32,6 +35,7 @@ const Container = styled.div`
3235
`;
3336

3437
const 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+
116130
export 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

Comments
 (0)