2024-01-07 18:05:04 +00:00
|
|
|
import React from 'react'
|
2023-12-24 02:10:03 +00:00
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
|
2023-12-31 21:17:04 +00:00
|
|
|
export interface LinkType {
|
2023-12-31 20:29:30 +00:00
|
|
|
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) {
|
2024-01-07 03:04:57 +00:00
|
|
|
return (<div className="">
|
|
|
|
<h3 className="">Link to this note</h3>
|
2023-12-24 02:10:03 +00:00
|
|
|
{(linkList != null && linkList.length > 0)
|
2024-01-07 18:05:04 +00:00
|
|
|
? <>
|
2024-01-07 03:04:57 +00:00
|
|
|
<div className="">
|
2023-12-24 02:10:03 +00:00
|
|
|
{linkList.map(aLink =>
|
2024-01-07 03:04:57 +00:00
|
|
|
<div key={aLink.slug} className="">
|
2024-01-07 18:05:04 +00:00
|
|
|
{/* <Link href={aLink.slug}> */}
|
2023-12-24 02:10:03 +00:00
|
|
|
<a href={aLink.slug}>
|
2024-01-07 03:04:57 +00:00
|
|
|
<p className="">{aLink.title}</p>
|
|
|
|
<p className="">{aLink.shortSummary} </p>
|
2023-12-24 02:10:03 +00:00
|
|
|
</a>
|
2024-01-07 18:05:04 +00:00
|
|
|
{/* </Link> */}
|
2023-12-24 02:10:03 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</>
|
2024-01-07 03:04:57 +00:00
|
|
|
: <> <p className=""> No backlinks found</p> </>}
|
2024-01-07 18:05:04 +00:00
|
|
|
</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) {
|
2024-01-07 18:05:04 +00:00
|
|
|
useRouter()
|
2022-04-19 01:48:11 +00:00
|
|
|
|
2023-12-24 02:10:03 +00:00
|
|
|
return (
|
|
|
|
|
2024-01-07 03:04:57 +00:00
|
|
|
<div className="flex-1 p-xl">
|
2023-12-24 02:10:03 +00:00
|
|
|
<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>
|
2024-01-07 18:05:04 +00:00
|
|
|
)
|
2023-12-24 02:10:03 +00:00
|
|
|
}
|
|
|
|
|
2023-12-31 20:29:30 +00:00
|
|
|
interface BackLinksGroupProps {
|
|
|
|
links: LinkType[]
|
|
|
|
}
|
|
|
|
|
|
|
|
function BackLinksGroup({ links }: BackLinksGroupProps) {
|
2024-01-07 18:05:04 +00:00
|
|
|
if (links?.length === 0) {
|
2022-03-31 08:46:10 +00:00
|
|
|
return (
|
2024-01-07 03:04:57 +00:00
|
|
|
<p className=""> No backlinks found</p>
|
2023-12-24 02:10:03 +00:00
|
|
|
)
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2024-01-07 18:05:04 +00:00
|
|
|
export default MDContent
|