From f2db0309ac18266a9d02d5cd1e86a1f3b76842c4 Mon Sep 17 00:00:00 2001 From: Duarte Dias Date: Sat, 9 Jan 2021 00:28:43 +0000 Subject: [PATCH] embed youtube videos on feed --- src/assets/javascripts/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/assets/javascripts/app.js b/src/assets/javascripts/app.js index 04cfde0..66ab0d0 100644 --- a/src/assets/javascripts/app.js +++ b/src/assets/javascripts/app.js @@ -48,6 +48,14 @@ var sanitize = function(content, base) { return sanitizer.sanitize(content, {FORBID_TAGS: ['style'], FORBID_ATTR: ['style', 'class']}) } +function extensions(details, content) { + const ytId = details.link.match(/youtube\.com\/watch\?v=(.*)$/)[1]; + if(ytId) { + content+=``; + } + return content; +} + Vue.use(VueLazyload) Vue.directive('scroll', { @@ -214,7 +222,7 @@ var vm = new Vue({ else if (this.itemSelectedDetails.description) content = this.itemSelectedDetails.description - return sanitize(content, this.itemSelectedDetails.link) + return extensions(this.itemSelectedDetails,sanitize(content, this.itemSelectedDetails.link)) }, }, watch: {