XeNote/components/MDContent.js

63 lines
2.2 KiB
JavaScript
Raw Normal View History

import React from 'react';
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
import {useRouter} from 'next/router'
function BackLinks({linkList}) {
2022-04-08 04:56:09 +00:00
return (<div className="note-footer">
<h3 className="backlink-heading">Link to this note</h3>
{(linkList != null && linkList.length > 0)
?
<>
<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-18 09:37:59 +00:00
{/*<Link href={aLink.slug}>*/}
<a href={aLink.slug}>
<p className="backlink-title">{aLink.title}</p>
<p className="backlink-preview">{aLink.shortSummary} </p>
</a>
2022-04-18 09:37:59 +00:00
{/*</Link>*/}
</div>
2022-04-08 04:56:09 +00:00
)}
</div>
</>
: <> <p className="no-backlinks"> No backlinks found</p> </>}
2022-04-08 04:56:09 +00:00
</div>);
}
function MDContent({content, backLinks, handleOpenNewContent}) {
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)
}
useRouter();
return (
<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>
<hr/>
<footer>
2022-04-19 08:15:54 +00:00
<p>Powered by <a href="https://github.com/TuanManhCao/digital-garden">Mind Stone</a>, © 2022</p>
</footer>
</div>
);
}
export default MDContent;