2022-03-31 08:46:10 +00:00
|
|
|
import React from 'react';
|
2023-12-24 02:10:03 +00:00
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
|
2023-12-31 20:29:30 +00:00
|
|
|
interface LinkType {
|
|
|
|
slug: string
|
|
|
|
title: string
|
|
|
|
shortSummary: string
|
|
|
|
}
|
|
|
|
|
2023-12-30 02:02:17 +00:00
|
|
|
interface BackLinksProps {
|
2023-12-31 20:29:30 +00:00
|
|
|
linkList: LinkType[]
|
2023-12-30 02:02:17 +00:00
|
|
|
}
|
2023-12-24 02:10:03 +00:00
|
|
|
|
2023-12-31 20:29:30 +00:00
|
|
|
function BackLinks({ linkList }: BackLinksProps) {
|
2023-12-24 02:10:03 +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">
|
|
|
|
{linkList.map(aLink =>
|
|
|
|
<div key={aLink.slug} className="backlink">
|
|
|
|
{/*<Link href={aLink.slug}>*/}
|
|
|
|
<a href={aLink.slug}>
|
|
|
|
<p className="backlink-title">{aLink.title}</p>
|
|
|
|
<p className="backlink-preview">{aLink.shortSummary} </p>
|
|
|
|
</a>
|
|
|
|
{/*</Link>*/}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
: <> <p className="no-backlinks"> No backlinks found</p> </>}
|
|
|
|
</div>);
|
2022-04-07 03:44:02 +00:00
|
|
|
}
|
|
|
|
|
2023-12-30 02:02:17 +00:00
|
|
|
|
|
|
|
interface MDContentProps {
|
2023-12-30 16:42:21 +00:00
|
|
|
content: string
|
2023-12-31 20:29:30 +00:00
|
|
|
backLinks: LinkType[]
|
2023-12-30 02:02:17 +00:00
|
|
|
}
|
|
|
|
|
2023-12-30 16:42:21 +00:00
|
|
|
function MDContent({ content, backLinks }: MDContentProps) {
|
2023-12-24 02:10:03 +00:00
|
|
|
useRouter();
|
2022-04-19 01:48:11 +00:00
|
|
|
|
2023-12-24 02:10:03 +00:00
|
|
|
return (
|
|
|
|
|
|
|
|
<div className="markdown-rendered">
|
|
|
|
<div dangerouslySetInnerHTML={{ __html: content }} />
|
|
|
|
<BackLinksGroup links={backLinks} />
|
|
|
|
<hr />
|
|
|
|
<footer>
|
|
|
|
<p>Powered by <a href="https://gitlab.com/Tarmstrong95">Triston</a>, © {new Date().getFullYear()}</p>
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-31 20:29:30 +00:00
|
|
|
interface BackLinksGroupProps {
|
|
|
|
links: LinkType[]
|
|
|
|
}
|
|
|
|
|
|
|
|
function BackLinksGroup({ links }: BackLinksGroupProps) {
|
2023-12-24 02:10:03 +00:00
|
|
|
|
|
|
|
if (!links?.length) {
|
2022-03-31 08:46:10 +00:00
|
|
|
return (
|
2023-12-24 02:10:03 +00:00
|
|
|
<p className="no-backlinks"> No backlinks found</p>
|
|
|
|
)
|
|
|
|
}
|
2022-03-31 09:59:10 +00:00
|
|
|
|
2023-12-24 02:10:03 +00:00
|
|
|
return (
|
|
|
|
<details>
|
|
|
|
<summary>
|
|
|
|
BackLinks
|
|
|
|
</summary>
|
|
|
|
<BackLinks linkList={links} />
|
|
|
|
</details>
|
|
|
|
)
|
2022-03-31 08:46:10 +00:00
|
|
|
}
|
|
|
|
|
2023-12-24 02:10:03 +00:00
|
|
|
export default MDContent;
|