From 4d58418328b5af3b80c234b722542b80a4cf18f5 Mon Sep 17 00:00:00 2001 From: tpmai22 Date: Sun, 30 Jan 2022 18:25:14 -0500 Subject: [PATCH] Make Youtube link clickable --- pnpm-lock.yaml | 16 ++++++++++++++++ src/api/posts/package.json | 2 ++ src/api/posts/src/data/post.js | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c2da9e1cb..37467567d8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -238,6 +238,8 @@ importers: ioredis: 4.28.2 ioredis-mock: 5.8.1 jsdom: 18.1.1 + linkify-html: ^3.0.5 + linkifyjs: ^3.0.5 normalize-url: 6.1.0 supertest: 6.1.6 dependencies: @@ -247,6 +249,8 @@ importers: ioredis: 4.28.2 ioredis-mock: 5.8.1_ioredis@4.28.2 jsdom: 18.1.1 + linkify-html: 3.0.5_linkifyjs@3.0.5 + linkifyjs: 3.0.5 normalize-url: 6.1.0 devDependencies: supertest: 6.1.6 @@ -10594,6 +10598,18 @@ packages: /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + /linkify-html/3.0.5_linkifyjs@3.0.5: + resolution: {integrity: sha512-3O7HEYjkugX+C/G2C2wyBmIt8Mt0pmeaHNIxRHodCFeQQeSxSoZHR+5hC1pi0WrmoEvfnSemyZyYTM8w3lo9cA==} + peerDependencies: + linkifyjs: ^3.0.0 + dependencies: + linkifyjs: 3.0.5 + dev: false + + /linkifyjs/3.0.5: + resolution: {integrity: sha512-1Y9XQH65eQKA9p2xtk+zxvnTeQBG7rdAXSkUG97DmuI/Xhji9uaUzaWxRj6rf9YC0v8KKHkxav7tnLX82Sz5Fg==} + dev: false + /listenercount/1.0.1: resolution: {integrity: sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc=} dev: true diff --git a/src/api/posts/package.json b/src/api/posts/package.json index b7174835da..a68a04ead8 100644 --- a/src/api/posts/package.json +++ b/src/api/posts/package.json @@ -22,6 +22,8 @@ "ioredis": "4.28.2", "ioredis-mock": "5.8.1", "jsdom": "18.1.1", + "linkify-html": "^3.0.5", + "linkifyjs": "^3.0.5", "normalize-url": "6.1.0" }, "devDependencies": { diff --git a/src/api/posts/src/data/post.js b/src/api/posts/src/data/post.js index df2c43df81..413716f46a 100644 --- a/src/api/posts/src/data/post.js +++ b/src/api/posts/src/data/post.js @@ -1,4 +1,5 @@ const { hash } = require('@senecacdot/satellite'); +const linkifyHtml = require('linkify-html'); const { getPost, addPost } = require('../storage'); const Feed = require('./feed'); const textParser = require('../text-parser'); @@ -59,7 +60,7 @@ class Post { // Use the post's guid as our unique identifier this.id = hash(guid); this.title = title; - this.html = html; + this.html = linkifyHtml(html); this.published = ensureDate(datePublished); this.updated = ensureDate(dateUpdated, datePublished); // create an absolute url if postURL is relative