Skip to content

Commit dcb582c

Browse files
committed
add markdown support
1 parent a0adc2b commit dcb582c

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"fromnow": "^3.0.1",
3434
"is-mobile": "^2.0.1",
3535
"isomorphic-unfetch": "^3.0.0",
36+
"md.js": "^0.2.6",
3637
"next": "^9.1.4",
3738
"nprogress": "^0.2.0",
3839
"qrcode.react": "^0.9.3",

src/components/CrowdFund/list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const CampaignList = () => {
4141
return (
4242
<li key={item.id} className="mx-0 my-4 md:mx-4">
4343
<Link href="/crowdfund/[slug]" as={`/crowdfund/${item.slug}`}>
44-
<a className="block p-4 px-6 bg-white shadow-lg rounded-lg" style={{ maxWidth: 360 }}>
44+
<a className="block p-4 px-6 bg-white shadow-lg rounded-lg" style={{ maxWidth: 420 }}>
4545
<h3 className="text-xl mb-1 font-medium text-gray-800">
4646
<span className="hidden md:block">{truncateString(item.title, 30)}</span>
4747
<span className="md:hidden">{item.title}</span>

src/pages/crowdfund/[slug].tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import useSWR from 'swr';
33
import Link from 'next/link';
4+
import snarkdown from 'md.js';
5+
46
import { NextPageContext, NextComponentType } from 'next';
57
import { SEO } from '../../components/SEO';
68
import { PaymentForm } from '../../components/common/PaymentForm';
@@ -35,9 +37,9 @@ const CampaignPage: NextPage = ({ initialData, slug }) => {
3537
<div className="p-4 pt-0 lg:flex">
3638
<div className="md:mx-2 md:mr-8 lg:flex-1">
3739
<h1 className="text-2xl mb-2 font-medium text-gray-800">{data.title}</h1>
38-
<p
40+
<div
3941
className="text-lg mb-4 text-gray-700 leading-relaxed markdown"
40-
dangerouslySetInnerHTML={{ __html: data.description }}
42+
dangerouslySetInnerHTML={{ __html: snarkdown(data.description) }}
4143
/>
4244
<CampaignProgress campaign={data} />
4345
{data.is_active && (

src/styles/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ body {
2121
.markdown > * + *,
2222
.markdown li + li,
2323
.markdown li > p + p {
24-
@apply mt-6;
24+
@apply mt-4;
2525
}
2626
.markdown strong {
2727
@apply text-black font-bold;

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4782,6 +4782,11 @@ map-visit@^1.0.0:
47824782
dependencies:
47834783
object-visit "^1.0.0"
47844784

4785+
md.js@^0.2.6:
4786+
version "0.2.6"
4787+
resolved "https://registry.yarnpkg.com/md.js/-/md.js-0.2.6.tgz#a2ff30c3ad4e9480bb2dbcddb238fb089a4137ef"
4788+
integrity sha1-ov8ww61OlIC7Lbzdsjj7CJpBN+8=
4789+
47854790
md5.js@^1.3.4:
47864791
version "1.3.5"
47874792
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"

0 commit comments

Comments
 (0)