@hobenakicoffee/libraries 1.25.0 → 1.27.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hobenakicoffee/libraries",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "type": "module",
5
5
  "types": "src/index.ts",
6
6
  "exports": {
@@ -1722,6 +1722,10 @@ export type Database = {
1722
1722
  Args: { p_post_id: string };
1723
1723
  Returns: undefined;
1724
1724
  };
1725
+ record_newsletter_post_view: {
1726
+ Args: { p_post_id: string };
1727
+ Returns: undefined;
1728
+ };
1725
1729
  request_withdrawal: {
1726
1730
  Args: { p_amount: number; p_payout_method_id: string };
1727
1731
  Returns: string;
@@ -0,0 +1,27 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { getNewsletterPostLink } from "./get-newsletter-post-link";
3
+
4
+ describe("getNewsletterPostLink", () => {
5
+ test("builds relative path without baseUrl", () => {
6
+ const result = getNewsletterPostLink("johndoe", "my-post");
7
+ expect(result).toBe("/@johndoe/posts/my-post");
8
+ });
9
+
10
+ test("builds absolute URL with baseUrl", () => {
11
+ const result = getNewsletterPostLink(
12
+ "johndoe",
13
+ "my-post",
14
+ "https://hobenaki.coffee"
15
+ );
16
+ expect(result).toBe("https://hobenaki.coffee/@johndoe/posts/my-post");
17
+ });
18
+
19
+ test("handles different usernames and slugs", () => {
20
+ expect(getNewsletterPostLink("alice", "welcome-newsletter")).toBe(
21
+ "/@alice/posts/welcome-newsletter"
22
+ );
23
+ expect(getNewsletterPostLink("bob", "updates-2024")).toBe(
24
+ "/@bob/posts/updates-2024"
25
+ );
26
+ });
27
+ });
@@ -0,0 +1,9 @@
1
+ export function getNewsletterPostLink(
2
+ username: string,
3
+ slug: string,
4
+ baseUrl?: string
5
+ ) {
6
+ return baseUrl
7
+ ? `${baseUrl}/@${username}/posts/${slug}`
8
+ : `/@${username}/posts/${slug}`;
9
+ }
@@ -4,6 +4,7 @@ export * from "./format-count";
4
4
  export * from "./format-date";
5
5
  export * from "./format-number";
6
6
  export * from "./format-plain-text";
7
+ export * from "./get-newsletter-post-link";
7
8
  export * from "./get-social-handle";
8
9
  export * from "./get-social-link";
9
10
  export * from "./get-user-name-initials";