Skip to content

Commit

Permalink
[site/components,#260][s]: modify/fix blogslist component after page …
Browse files Browse the repository at this point in the history
…description changes
  • Loading branch information
khalilcodes committed Feb 19, 2023
1 parent b2c5d06 commit 266dfd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
11 changes: 1 addition & 10 deletions site/content/components/BlogsList.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { useState } from "react";
import { formatDate } from "@/lib/formatDate.js";
import { PostBody } from "./getPageBody.jsx";

const BLOGS_LOAD_COUNT = 5

// function getBody(post) {
// const body = /^[A-Za-z0-9 ].*/gm.exec(post)
// return body[0]
// }

export function BlogsList({ posts }) {
const [postsCount, setPostsCount] = useState(BLOGS_LOAD_COUNT);

Expand Down Expand Up @@ -55,10 +49,7 @@ export function BlogsList({ posts }) {
</div>}
</div>
<div className="flex flex-col space-y-1">
{post.description
? <p className="my-0">{post.description}</p>
: <PostBody code={post.body.code} frontmatterImage />
}
{post.description && <p className="my-0 line-clamp-3">{post.description}</p>}
<a href={post.url_path} className="text-sm text-gray-500 hover:text-gray-900 pt-2 w-fit">{"[ Read more ]"}</a>
</div>
</li>
Expand Down
3 changes: 3 additions & 0 deletions site/lib/parseMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ export function parseMarkdown(markdownText) {
markdownText = markdownText.replace(/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/gm, '');
// remove images
markdownText = markdownText.replace(/!\[(.*?)\]\((.*?)\)/g, '');
// Remove HTML elements
markdownText = markdownText.replace(/<[^>]*>/g, '');

return markdownText;
}

0 comments on commit 266dfd1

Please sign in to comment.