ptn-helpers 0.0.5 → 0.0.10

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.
Files changed (2) hide show
  1. package/lib/index.js +11 -3
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@ var FEED_LINK_KEYS = [
8
8
  "_ptr_open_graph_type",
9
9
  ];
10
10
  var itemToNode = function (feedItem, hashtag) {
11
- var _a, _b, _c, _d, _e, _f, _g;
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
12
12
  var children = [];
13
13
  var attachment = (_a = feedItem === null || feedItem === void 0 ? void 0 : feedItem.attachments) === null || _a === void 0 ? void 0 : _a[0];
14
14
  var text = (_b = feedItem === null || feedItem === void 0 ? void 0 : feedItem.content_text) !== null && _b !== void 0 ? _b : "";
@@ -29,17 +29,25 @@ var itemToNode = function (feedItem, hashtag) {
29
29
  }
30
30
  });
31
31
  }
32
+ else if ((attachment === null || attachment === void 0 ? void 0 : attachment._ptr_media_type) === "text") {
33
+ if ((_f = (_e = attachment === null || attachment === void 0 ? void 0 : attachment.title) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0 > 0) {
34
+ children.push({
35
+ text: "".concat(attachment.title),
36
+ children: [],
37
+ });
38
+ }
39
+ }
32
40
  else if ((attachment === null || attachment === void 0 ? void 0 : attachment._ptr_media_type) === "image") {
33
41
  text = "![](".concat(attachment.url, ")");
34
42
  }
35
43
  else if ((attachment === null || attachment === void 0 ? void 0 : attachment._ptr_media_type) === "audio") {
36
- var title = ((_f = (_e = feedItem.content_text) === null || _e === void 0 ? void 0 : _e.trim()) === null || _f === void 0 ? void 0 : _f.length) > 0 ? feedItem.content_text : "Audio Recording";
44
+ var title = ((_h = (_g = feedItem.content_text) === null || _g === void 0 ? void 0 : _g.trim()) === null || _h === void 0 ? void 0 : _h.length) > 0 ? feedItem.content_text : "Audio Recording";
37
45
  text = "[".concat(title, "](").concat(attachment.url, ")");
38
46
  }
39
47
  text = "".concat(text.trim());
40
48
  var validHashtag = hashtag && typeof hashtag === "string" && hashtag.length > 0;
41
49
  var existingTags = /#\w+to(roam|note)/;
42
- var needsNewTag = !!!((_g = text.match(existingTags)) === null || _g === void 0 ? void 0 : _g.length);
50
+ var needsNewTag = !!!((_j = text.match(existingTags)) === null || _j === void 0 ? void 0 : _j.length);
43
51
  if (validHashtag && needsNewTag) {
44
52
  text = "".concat(text, " #").concat(hashtag);
45
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ptn-helpers",
3
- "version": "0.0.5",
3
+ "version": "0.0.10",
4
4
  "description": "helper functions to fetch and display ptn data",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",