2022-03-31 08:46:10 +00:00
|
|
|
import React from 'react';
|
|
|
|
import Alert from '@mui/material/Alert';
|
|
|
|
import AlertTitle from '@mui/material/AlertTitle';
|
2022-03-31 09:59:10 +00:00
|
|
|
import {useRouter} from 'next/router'
|
2022-04-07 03:44:02 +00:00
|
|
|
import Link from 'next/link'
|
2022-03-31 08:46:10 +00:00
|
|
|
|
2022-04-07 03:44:02 +00:00
|
|
|
function BackLinks({linkList}) {
|
|
|
|
|
2022-04-08 04:56:09 +00:00
|
|
|
return (<div className="note-footer">
|
|
|
|
{(linkList != null && linkList.length > 0)
|
2022-04-07 03:44:02 +00:00
|
|
|
?
|
2022-04-08 04:56:09 +00:00
|
|
|
<>
|
|
|
|
<h3 className="backlink-heading">Link to this note</h3>
|
|
|
|
|
|
|
|
<div className="backlink-container">
|
|
|
|
{linkList.map(aLink =>
|
|
|
|
<div className="backlink">
|
|
|
|
<Link href={aLink.slug}>
|
|
|
|
<a >
|
|
|
|
<p className="backlink-title">{aLink.title}</p>
|
|
|
|
<p className="backlink-preview">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsumLorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum </p>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
|
|
|
|
: <></>}
|
|
|
|
</div>);
|
2022-04-07 03:44:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MDContent({content, fileNames, backLinks, handleOpenNewContent}) {
|
2022-03-31 09:59:10 +00:00
|
|
|
|
|
|
|
function handleInternalLinkClick() {
|
|
|
|
//Processing fetching
|
|
|
|
//pass result up to parent container
|
|
|
|
//TODO: handle clicking on internal link, go fetching md content from file then passing it up to parent
|
|
|
|
handleOpenNewContent(content)
|
|
|
|
}
|
2022-04-07 03:44:02 +00:00
|
|
|
|
2022-03-31 09:59:10 +00:00
|
|
|
const router = useRouter();
|
2022-03-31 08:46:10 +00:00
|
|
|
return (
|
2022-03-31 09:59:10 +00:00
|
|
|
|
2022-04-07 03:44:02 +00:00
|
|
|
<div className="markdown-rendered">
|
|
|
|
<Alert severity="info">
|
|
|
|
<AlertTitle>Want to know more?</AlertTitle>
|
|
|
|
🌱 <strong>Follow</strong> or <strong>DM</strong> me on Twitter at <span><a
|
|
|
|
href="https://twitter.com/tuancm">@tuancm</a></span>
|
|
|
|
</Alert>
|
|
|
|
<div dangerouslySetInnerHTML={{__html: content}}/>
|
|
|
|
<button onClick={handleInternalLinkClick}>Click me</button>
|
|
|
|
<hr/>
|
|
|
|
<div>
|
|
|
|
<BackLinks linkList={backLinks}/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-31 08:46:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MDContent;
|