From 0be574cb0034efc63f7a04c34950b0797ec3045c Mon Sep 17 00:00:00 2001 From: Yu Yongwoo Date: Wed, 25 Jan 2017 12:40:04 +0900 Subject: [PATCH] facebook share parmameter apply markdown to string --- package.json | 2 ++ src/app/components/post/detail/post.detail.component.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e0f6535..1587641 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "core-js": "^2.4.1", "firebase": "^3.6.5", "lodash": "^4.17.4", + "mdast-util-to-string": "^1.0.2", "ng2-imageupload": "^1.3.0", + "remark": "^6.2.0", "rxjs": "^5.0.1", "simplemde": "^1.11.2", "ts-helpers": "^1.1.1", diff --git a/src/app/components/post/detail/post.detail.component.ts b/src/app/components/post/detail/post.detail.component.ts index 9c9016a..4f432b8 100644 --- a/src/app/components/post/detail/post.detail.component.ts +++ b/src/app/components/post/detail/post.detail.component.ts @@ -8,6 +8,9 @@ import {User} from "../../../model/user.model"; import {AuthService} from "../../../service/auth.service"; import {Observable} from "rxjs"; +import remark from "remark"; +import md2string from "mdast-util-to-string"; + declare const $: any; declare const marked: any; @@ -135,7 +138,7 @@ export class PostDetailComponent implements OnInit { onShareInFacebook() { let url = location.href; let image = this.imageURL || 'https://yop.cool/assets/img/share.png'; - window.open(`https://www.facebook.com/v2.1/dialog/feed?&app_id=1404961129515494&caption=YOP: Year Of Programmers&description=${encodeURIComponent(this.body)}&display=popup&locale=ko_KR&name=${encodeURIComponent(this.title)}&link=${encodeURIComponent(url)}&picture=${image}&version=v2.1`, + window.open(`https://www.facebook.com/v2.1/dialog/feed?&app_id=1404961129515494&caption=YOP: Year Of Programmers&description=${encodeURIComponent(md2string(remark().parse(this.body)))}&display=popup&locale=ko_KR&name=${encodeURIComponent(this.title)}&link=${encodeURIComponent(url)}&picture=${image}&version=v2.1`, 'facebookShare', 'toolbar=0,status=0,width=625,height=435' );