Files
Blog/components/BlogList.js
Eli Winderickx 1a10fcdf49 Grafische overhoal & Post sort
modified:   components/BlogList.js
	modified:   components/Header.js
	modified:   components/Layout.js
	deleted:    data/info.md
	new file:   data/over.md
	renamed:    pages/info.js -> pages/over.js
	renamed:    posts/24Jun-zabbix-prom.md -> posts/23-06-24-zabbix-prom.md
	renamed:    posts/1Jul-SELinuxMetZabbix.md -> posts/23-07-01-SELinuxMetZabbix.md
	renamed:    posts/9Jul-zabbix-ha-cluster.md -> posts/23-07-09-Zabbix-ha-cluster.md
	renamed:    posts/16Jul-rebranding-zabbix.md -> posts/23-07-16-Rebranding-zabbix.md
	renamed:    posts/21Jul-OpenSSH.md -> posts/23-07-21-OpenSSH.md
	renamed:    posts/22Jul-Permissions.md -> posts/23-07-22-Permissions.md
	renamed:    posts/24Jul-SyncRepo.md -> posts/23-07-24-SyncRepo.md
	renamed:    posts/28Jul-SystemdApps.md -> posts/23-07-28-SystemdApps.md
	renamed:    posts/31Jul-SELinux.md -> posts/23-07-31-SELinux.md
	renamed:    posts/1Aug-Documentatie.md -> posts/23-08-01-Documentatie.md
	renamed:    posts/10Aug-AWK_basis.md -> posts/23-08-10-AWK_basis.md
	renamed:    posts/16Aug-GetAGrep.md -> posts/23-08-16-GetAGrep.md
	renamed:    posts/23Aug-Git_masterclass.md -> posts/23-08-23-Git_masterclass.md
	renamed:    posts/30Aug-ZabbixBackup.md -> posts/23-08-30-ZabbixBackup.md
	renamed:    posts/6Sept-Kickstart.md -> posts/23-09-06-Kickstart.md
	renamed:    posts/27Sept-GitlabUpgrade.md -> posts/23-09-27-GitlabUpgrade.md
	renamed:    posts/4Okt-HashicorpVault.md -> posts/23-10-04-HashicorpVault.md
	renamed:    posts/8Okt-Certbot.md -> posts/23-10-08-Certbot.md
	renamed:    posts/11Okt-HashicorpVault.md -> posts/23-10-11-HashicorpVault.md
	renamed:    posts/12Okt_ACL.md -> posts/23-10-12-ACL.md
	renamed:    posts/18Okt-InABind.md -> posts/23-10-18-InABind.md
	renamed:    posts/23Okt-Autofs.md -> posts/23-10-23-Autofs.md
	renamed:    posts/25Okt-RPM.md -> posts/23-10-25-RPM.md
	renamed:    posts/26Okt-Journald.md -> posts/23-10-26-Journald.md
	modified:   styles/Info.module.css
2024-03-24 20:34:27 +01:00

51 lines
1.8 KiB
JavaScript

import Link from "next/link"
import ReactMarkdown from "react-markdown"
import styles from "../styles/BlogList.module.css"
import Image from "next/image"
function truncateSummary(content) {
return content.slice(0, 200).trimEnd()
}
function reformatDate(fullDate) {
const date = new Date(fullDate)
return date.toDateString().slice(4)
}
const BlogList = ({ allBlogs }) => {
return (
<ul>
{
allBlogs && allBlogs.length > 1 &&
allBlogs
.sort((post1,post2) => {
if(post1.slug < post2.slug) return 1
if(post1.slug > post2.slug) return -1
return 0
})
.map(post => (
<li key={post.slug}>
<Link href={{ pathname: `/blog/${post.slug}` }} className={styles.blog__link}>
<div className={styles.hero_image}>
<Image
width={384}
height={288}
src={post.frontmatter.hero_image}
alt={post.frontmatter.hero_image}
/>
</div>
<div className={styles.blog__info}>
<h2>{post.frontmatter.title}</h2>
<h3>{reformatDate(post.frontmatter.date)}</h3>
<ReactMarkdown disallowedElements={["a"]}>{truncateSummary(post.markdownBody)}</ReactMarkdown>
</div>
</Link>
</li>
))
}
</ul>
)
}
export default BlogList