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">
|
2022-04-13 07:30:00 +00:00
|
|
|
{(linkList != null && linkList.length > 0)
|
|
|
|
?
|
|
|
|
<>
|
|
|
|
<h3 className="backlink-heading">Link to this note</h3>
|
|
|
|
<div className="backlink-container">
|
2022-04-08 04:56:09 +00:00
|
|
|
{linkList.map(aLink =>
|
2022-04-15 04:20:32 +00:00
|
|
|
<div key={aLink.slug} className="backlink">
|
2022-04-13 07:30:00 +00:00
|
|
|
<Link href={aLink.slug}>
|
|
|
|
<a>
|
2022-04-08 04:56:09 +00:00
|
|
|
<p className="backlink-title">{aLink.title}</p>
|
2022-04-08 07:44:45 +00:00
|
|
|
<p className="backlink-preview">{aLink.shortSummary} </p>
|
2022-04-13 07:30:00 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</div>
|
2022-04-08 04:56:09 +00:00
|
|
|
)}
|
2022-04-13 07:30:00 +00:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
: <></>}
|
2022-04-08 04:56:09 +00:00
|
|
|
</div>);
|
2022-04-07 03:44:02 +00:00
|
|
|
}
|
|
|
|
|
2022-04-17 13:04:58 +00:00
|
|
|
function MDContent({content, 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-17 13:04:58 +00:00
|
|
|
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}}/>
|
2022-04-08 07:44:45 +00:00
|
|
|
{/*<button onClick={handleInternalLinkClick}>Click me</button>*/}
|
|
|
|
{/*<hr/>*/}
|
2022-04-07 03:44:02 +00:00
|
|
|
<div>
|
|
|
|
<BackLinks linkList={backLinks}/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-31 08:46:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MDContent;
|