Skip to content

Commit

Permalink
Removes markdown from Head description (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiVanOs authored Apr 8, 2023
1 parent 27e0e01 commit dfaa70a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@types/node": "17.0.33",
"@types/qs": "^6.9.7",
"@types/react": "18.0.33",
"@types/remove-markdown": "^0.3.1",
"autoprefixer": "^10.4.14",
"axios": "^1.3.5",
"eslint": "8.38.0",
Expand All @@ -29,6 +30,7 @@
"react-leaflet": "^4.2.1",
"react-markdown": "^8.0.6",
"remark-gfm": "^3.0.1",
"remove-markdown": "^0.5.0",
"tailwindcss": "^3.3.1",
"typescript": "4.9.4"
},
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/HeadArticle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import joinPaths from "../utils/paths";
import Head from "next/head";
import { PostDetail } from "../models/Post";
import RemoveMarkdown from "remove-markdown";

const DESCRIPTION_LENGTH = 160;

Expand All @@ -9,7 +10,7 @@ interface Props {
}

export default function HeadArticle({ post }: Props) {
let description = post.content.slice(
let description = RemoveMarkdown(post.content).slice(
0,
Math.min(DESCRIPTION_LENGTH, post.content.length)
);
Expand Down
10 changes: 10 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@
"@types/scheduler" "*"
csstype "^3.0.2"

"@types/remove-markdown@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@types/remove-markdown/-/remove-markdown-0.3.1.tgz#82bc3664c313f50f7c77f1bb59935f567689dc63"
integrity sha512-JpJNEJEsmmltyL2LdE8KRjJ0L2ad5vgLibqNj85clohT9AyTrfN6jvHxStPshDkmtcL/ShFu0p2tbY7DBS1mqQ==

"@types/scheduler@*":
version "0.16.2"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
Expand Down Expand Up @@ -2661,6 +2666,11 @@ remark-rehype@^10.0.0:
mdast-util-to-hast "^12.1.0"
unified "^10.0.0"

remove-markdown@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.5.0.tgz#a596264bbd60b9ceab2e2ae86e5789eee91aee32"
integrity sha512-x917M80K97K5IN1L8lUvFehsfhR8cYjGQ/yAMRI9E7JIKivtl5Emo5iD13DhMr+VojzMCiYk8V2byNPwT/oapg==

resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
Expand Down

0 comments on commit dfaa70a

Please sign in to comment.