nodebb-plugin-link-preview 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/library.js CHANGED
@@ -178,7 +178,7 @@ async function render(preview) {
178
178
  async function handleSpecialEmbed(url, $anchor) {
179
179
  const { app } = require.main.require('./src/webserver');
180
180
  const { hostname, searchParams, pathname } = new URL(url);
181
- const { embedYoutube, embedVimeo } = await meta.settings.get('link-preview');
181
+ const { embedYoutube, embedVimeo, embedTiktok } = await meta.settings.get('link-preview');
182
182
 
183
183
  if (embedYoutube === 'on' && ['youtube.com', 'www.youtube.com', 'youtu.be'].some(x => hostname === x)) {
184
184
  let video;
@@ -201,6 +201,14 @@ async function handleSpecialEmbed(url, $anchor) {
201
201
  return true;
202
202
  }
203
203
 
204
+ if (embedTiktok === 'on' && ['tiktok.com', 'www.tiktok.com'].some(x => hostname === x)) {
205
+ const video = pathname.split('/')[3];
206
+ const html = await app.renderAsync('partials/link-preview/tiktok', { video });
207
+ $anchor.replaceWith(html);
208
+
209
+ return true;
210
+ }
211
+
204
212
  return false;
205
213
  }
206
214
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-link-preview",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "A starter kit for quickly creating NodeBB plugins",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -54,6 +54,11 @@
54
54
  <input type="checkbox" class="form-check-input" id="embedVimeo" name="embedVimeo">
55
55
  <label for="embedVimeo" class="form-check-label">Vimeo</label>
56
56
  </div>
57
+
58
+ <div class="form-check form-switch mb-3">
59
+ <input type="checkbox" class="form-check-input" id="embedTiktok" name="embedTiktok">
60
+ <label for="embedTiktok" class="form-check-label">Vimeo</label>
61
+ </div>
57
62
  </div>
58
63
  </form>
59
64
  </div>
@@ -0,0 +1,3 @@
1
+ <div class="ratio" style="--bs-aspect-ratio: 200%;">
2
+ <iframe src="https://www.tiktok.com/embed/v2/{video}" title="TikTok video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
3
+ </div>