@content-streamline/nextjs 0.0.1 → 0.0.3
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/dist/api/client.d.ts +3 -3
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +9 -4
- package/dist/cache/file-cache.d.ts +1 -1
- package/dist/cache/file-cache.d.ts.map +1 -1
- package/dist/components/PostDetail.d.ts +1 -1
- package/dist/components/PostDetail.d.ts.map +1 -1
- package/dist/components/PostsList.d.ts +9 -2
- package/dist/components/PostsList.d.ts.map +1 -1
- package/dist/components/PostsList.js +7 -3
- package/dist/components/index.d.ts +4 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/server/index.d.ts +4 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +15 -5
- package/package.json +1 -2
package/dist/api/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content Streamline Public API Client
|
|
3
3
|
*/
|
|
4
|
-
import type { Post, PostDetailResponse, PostsResponse } from '../types';
|
|
4
|
+
import type { Post, PostDetailResponse, PostsResponse } from '../types/index.js';
|
|
5
5
|
declare class ContentStreamlineAPI {
|
|
6
6
|
private baseUrl;
|
|
7
7
|
private accessToken;
|
|
@@ -10,11 +10,11 @@ declare class ContentStreamlineAPI {
|
|
|
10
10
|
/**
|
|
11
11
|
* List all posts with pagination
|
|
12
12
|
*/
|
|
13
|
-
listPosts(page?: number): Promise<PostsResponse>;
|
|
13
|
+
listPosts(page?: number, platform?: string): Promise<PostsResponse>;
|
|
14
14
|
/**
|
|
15
15
|
* Get all posts by fetching all pages
|
|
16
16
|
*/
|
|
17
|
-
getAllPosts(): Promise<Post[]>;
|
|
17
|
+
getAllPosts(platform?: string): Promise<Post[]>;
|
|
18
18
|
/**
|
|
19
19
|
* Get a single post by ID
|
|
20
20
|
*/
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACd,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,cAAM,oBAAoB;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;YAKlC,KAAK;IAiCnB;;OAEG;IACG,SAAS,CAAC,IAAI,GAAE,MAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAS5E;;OAEG;IACG,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAgBrD;;OAEG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,GAAE,UAAU,GAAG,MAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAIxG;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,oBAAoB,CAE1F"}
|
package/dist/api/client.js
CHANGED
|
@@ -38,18 +38,23 @@ class ContentStreamlineAPI {
|
|
|
38
38
|
/**
|
|
39
39
|
* List all posts with pagination
|
|
40
40
|
*/
|
|
41
|
-
async listPosts(page = 1) {
|
|
42
|
-
|
|
41
|
+
async listPosts(page = 1, platform) {
|
|
42
|
+
const params = new URLSearchParams();
|
|
43
|
+
params.set('page', page.toString());
|
|
44
|
+
if (platform) {
|
|
45
|
+
params.set('platform', platform);
|
|
46
|
+
}
|
|
47
|
+
return this.fetch(`/public/v1/posts?${params.toString()}`);
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* Get all posts by fetching all pages
|
|
46
51
|
*/
|
|
47
|
-
async getAllPosts() {
|
|
52
|
+
async getAllPosts(platform) {
|
|
48
53
|
const allPosts = [];
|
|
49
54
|
let currentPage = 1;
|
|
50
55
|
let hasMore = true;
|
|
51
56
|
while (hasMore) {
|
|
52
|
-
const response = await this.listPosts(currentPage);
|
|
57
|
+
const response = await this.listPosts(currentPage, platform);
|
|
53
58
|
allPosts.push(...response.data);
|
|
54
59
|
hasMore = response.pagination.next_page !== null;
|
|
55
60
|
currentPage = response.pagination.next_page || currentPage + 1;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* File-based cache for posts
|
|
3
3
|
* Works in Next.js server environment
|
|
4
4
|
*/
|
|
5
|
-
import type { Post, PostDetailResponse, CachedPostIndex } from '../types';
|
|
5
|
+
import type { Post, PostDetailResponse, CachedPostIndex } from '../types/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Initialize cache directory
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-cache.d.ts","sourceRoot":"","sources":["../../src/cache/file-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"file-cache.d.ts","sourceRoot":"","sources":["../../src/cache/file-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMnF;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAO/C;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAS9E;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAa,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAS3G;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CA0BzD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBnE;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAOrE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,aAAa,GAAE,MAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CASrF;AAED;;GAEG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAYhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostDetail.d.ts","sourceRoot":"","sources":["../../src/components/PostDetail.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PostDetail.d.ts","sourceRoot":"","sources":["../../src/components/PostDetail.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IACrD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;CACtH;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,OAAa,EACb,QAAe,EACf,SAAc,EACd,YAAmB,EACnB,QAAe,EACf,QAAe,EACf,SAAgB,EAChB,WAAkB,EAClB,aAAa,EACb,WAAW,GACZ,EAAE,eAAe,2CAoGjB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { Post } from '../types';
|
|
2
|
+
import type { Post } from '../types/index.js';
|
|
3
3
|
export interface PostsListProps {
|
|
4
4
|
posts: Post[];
|
|
5
5
|
/**
|
|
@@ -7,6 +7,13 @@ export interface PostsListProps {
|
|
|
7
7
|
* Post URL will be: {baseUrl}/{postId}/{slug}
|
|
8
8
|
*/
|
|
9
9
|
baseUrl?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Platform filter for posts (default: 'blog')
|
|
12
|
+
* Valid values: 'x', 'linkedin', 'blog', 'facebook', 'instagram', 'other'
|
|
13
|
+
* Filters the posts to only show those matching this platform.
|
|
14
|
+
* For best performance, also pass platform to getAllPosts() when fetching.
|
|
15
|
+
*/
|
|
16
|
+
platform?: string;
|
|
10
17
|
/**
|
|
11
18
|
* Language to use for post translations (default: 'en')
|
|
12
19
|
*/
|
|
@@ -40,5 +47,5 @@ export interface PostsListProps {
|
|
|
40
47
|
*/
|
|
41
48
|
renderExcerpt?: (post: Post, translation: Post['post_translations'][0]) => React.ReactNode;
|
|
42
49
|
}
|
|
43
|
-
export declare function PostsList({ posts, baseUrl, language, className, cardClassName, showDate, showExcerpt, showImages, renderTitle, renderExcerpt, }: PostsListProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare function PostsList({ posts, baseUrl, platform, language, className, cardClassName, showDate, showExcerpt, showImages, renderTitle, renderExcerpt, }: PostsListProps): import("react/jsx-runtime").JSX.Element;
|
|
44
51
|
//# sourceMappingURL=PostsList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostsList.d.ts","sourceRoot":"","sources":["../../src/components/PostsList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PostsList.d.ts","sourceRoot":"","sources":["../../src/components/PostsList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IACzF;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;CAC5F;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,OAAkB,EAClB,QAAiB,EACjB,QAAe,EACf,SAAc,EACd,aAAkB,EAClB,QAAe,EACf,WAAkB,EAClB,UAAiB,EACjB,WAAW,EACX,aAAa,GACd,EAAE,cAAc,2CAmFhB"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
export function PostsList({ posts, baseUrl = '/posts', language = 'en', className = '', cardClassName = '', showDate = true, showExcerpt = true, showImages = true, renderTitle, renderExcerpt, }) {
|
|
4
|
-
|
|
3
|
+
export function PostsList({ posts, baseUrl = '/posts', platform = 'blog', language = 'en', className = '', cardClassName = '', showDate = true, showExcerpt = true, showImages = true, renderTitle, renderExcerpt, }) {
|
|
4
|
+
// Filter posts by platform if specified
|
|
5
|
+
const filteredPosts = platform
|
|
6
|
+
? posts.filter(post => post.platform.toLowerCase() === platform.toLowerCase())
|
|
7
|
+
: posts;
|
|
8
|
+
if (filteredPosts.length === 0) {
|
|
5
9
|
return (_jsx("div", { className: `content-streamline-empty ${className}`, children: _jsx("p", { children: "No posts found." }) }));
|
|
6
10
|
}
|
|
7
|
-
return (_jsx("div", { className: `content-streamline-posts-list ${className}`, children:
|
|
11
|
+
return (_jsx("div", { className: `content-streamline-posts-list ${className}`, children: filteredPosts.map((post) => {
|
|
8
12
|
const translation = post.post_translations.find((t) => t.language === language) ||
|
|
9
13
|
post.post_translations[0];
|
|
10
14
|
if (!translation || !translation.slug)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content Streamline React Components
|
|
3
3
|
*/
|
|
4
|
-
export { PostsList } from './PostsList';
|
|
5
|
-
export { PostDetail } from './PostDetail';
|
|
6
|
-
export type { PostsListProps } from './PostsList';
|
|
7
|
-
export type { PostDetailProps } from './PostDetail';
|
|
4
|
+
export { PostsList } from './PostsList.js';
|
|
5
|
+
export { PostDetail } from './PostDetail.js';
|
|
6
|
+
export type { PostsListProps } from './PostsList.js';
|
|
7
|
+
export type { PostDetailProps } from './PostDetail.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content Streamline React Components
|
|
3
3
|
*/
|
|
4
|
-
export { PostsList } from './PostsList';
|
|
5
|
-
export { PostDetail } from './PostDetail';
|
|
4
|
+
export { PostsList } from './PostsList.js';
|
|
5
|
+
export { PostDetail } from './PostDetail.js';
|
|
6
6
|
// Styles are available at '@content-streamline/nextjs/components/styles.css'
|
|
7
7
|
// Users should import them in their app: import '@content-streamline/nextjs/components/styles.css'
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Content Streamline Next.js Library
|
|
3
3
|
* Main entry point
|
|
4
4
|
*/
|
|
5
|
-
export type { Post, PostDetailResponse, PostTranslation, PostImage, PostsResponse, Pagination, } from './types';
|
|
6
|
-
export { getAllPosts, getPost, getPostBySlug, } from './server';
|
|
7
|
-
export { PostsList, PostDetail, } from './components';
|
|
8
|
-
export type { PostsListProps, PostDetailProps, } from './components';
|
|
5
|
+
export type { Post, PostDetailResponse, PostTranslation, PostImage, PostsResponse, Pagination, } from './types/index.js';
|
|
6
|
+
export { getAllPosts, getPost, getPostBySlug, } from './server/index.js';
|
|
7
|
+
export { PostsList, PostDetail, } from './components/index.js';
|
|
8
|
+
export type { PostsListProps, PostDetailProps, } from './components/index.js';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,IAAI,EACJ,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,GACX,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,IAAI,EACJ,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,GACX,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,OAAO,EACP,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,SAAS,EACT,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,cAAc,EACd,eAAe,GAChB,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Main entry point
|
|
4
4
|
*/
|
|
5
5
|
// Export server functions
|
|
6
|
-
export { getAllPosts, getPost, getPostBySlug, } from './server';
|
|
6
|
+
export { getAllPosts, getPost, getPostBySlug, } from './server/index.js';
|
|
7
7
|
// Export components
|
|
8
|
-
export { PostsList, PostDetail, } from './components';
|
|
8
|
+
export { PostsList, PostDetail, } from './components/index.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Server-side functions for Next.js
|
|
3
3
|
* Use these in Server Components, API Routes, or getServerSideProps
|
|
4
4
|
*/
|
|
5
|
-
import type { Post, PostDetailResponse } from '../types';
|
|
5
|
+
import type { Post, PostDetailResponse } from '../types/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Get all posts (with automatic cache refresh)
|
|
8
8
|
* Use this in Server Components or API Routes
|
|
@@ -10,6 +10,7 @@ import type { Post, PostDetailResponse } from '../types';
|
|
|
10
10
|
export declare function getAllPosts(options?: {
|
|
11
11
|
maxCacheAge?: number;
|
|
12
12
|
forceRefresh?: boolean;
|
|
13
|
+
platform?: string;
|
|
13
14
|
}): Promise<Post[]>;
|
|
14
15
|
/**
|
|
15
16
|
* Get a single post by ID
|
|
@@ -30,6 +31,7 @@ export declare function getPostBySlug(slug: string, options?: {
|
|
|
30
31
|
contentFormat?: 'markdown' | 'html';
|
|
31
32
|
maxCacheAge?: number;
|
|
32
33
|
forceRefresh?: boolean;
|
|
34
|
+
platform?: string;
|
|
33
35
|
}): Promise<PostDetailResponse | null>;
|
|
34
|
-
export type { Post, PostDetailResponse, PostTranslation, PostImage, PostsResponse, Pagination, } from '../types';
|
|
36
|
+
export type { Post, PostDetailResponse, PostTranslation, PostImage, PostsResponse, Pagination, } from '../types/index.js';
|
|
35
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAkBlE;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,CAAC,EAAE;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CA2ClB;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GACA,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAiCpC;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACA,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA2BpC;AAGD,YAAY,EACV,IAAI,EACJ,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,GACX,MAAM,mBAAmB,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Server-side functions for Next.js
|
|
3
3
|
* Use these in Server Components, API Routes, or getServerSideProps
|
|
4
4
|
*/
|
|
5
|
-
import { createAPIClient } from '../api/client';
|
|
6
|
-
import { getAllCachedPosts, getCachedPost, cachePost, updatePostsIndex, shouldRefreshCache, } from '../cache/file-cache';
|
|
5
|
+
import { createAPIClient } from '../api/client.js';
|
|
6
|
+
import { getAllCachedPosts, getCachedPost, cachePost, updatePostsIndex, shouldRefreshCache, } from '../cache/file-cache.js';
|
|
7
7
|
/**
|
|
8
8
|
* Get API configuration from environment variables
|
|
9
9
|
*/
|
|
@@ -20,21 +20,30 @@ function getAPIConfig() {
|
|
|
20
20
|
* Use this in Server Components or API Routes
|
|
21
21
|
*/
|
|
22
22
|
export async function getAllPosts(options) {
|
|
23
|
-
const { maxCacheAge = 60, forceRefresh = false } = options || {};
|
|
23
|
+
const { maxCacheAge = 60, forceRefresh = false, platform } = options || {};
|
|
24
24
|
// Check cache freshness
|
|
25
25
|
if (!forceRefresh) {
|
|
26
26
|
const needsRefresh = await shouldRefreshCache(maxCacheAge);
|
|
27
27
|
if (!needsRefresh) {
|
|
28
28
|
const cached = await getAllCachedPosts();
|
|
29
29
|
if (cached.length > 0) {
|
|
30
|
-
|
|
30
|
+
// Filter cached posts by platform if specified
|
|
31
|
+
if (platform) {
|
|
32
|
+
const filtered = cached.filter(post => post.platform.toLowerCase() === platform.toLowerCase());
|
|
33
|
+
if (filtered.length > 0) {
|
|
34
|
+
return filtered;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
// Fetch from API
|
|
35
44
|
const { baseUrl, accessToken } = getAPIConfig();
|
|
36
45
|
const api = createAPIClient(baseUrl, accessToken);
|
|
37
|
-
const posts = await api.getAllPosts();
|
|
46
|
+
const posts = await api.getAllPosts(platform);
|
|
38
47
|
// Cache all posts
|
|
39
48
|
for (const post of posts) {
|
|
40
49
|
try {
|
|
@@ -88,6 +97,7 @@ export async function getPostBySlug(slug, options) {
|
|
|
88
97
|
const posts = await getAllPosts({
|
|
89
98
|
maxCacheAge: options?.maxCacheAge,
|
|
90
99
|
forceRefresh: options?.forceRefresh,
|
|
100
|
+
platform: options?.platform,
|
|
91
101
|
});
|
|
92
102
|
const language = options?.language || 'en';
|
|
93
103
|
// Find post with matching slug
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@content-streamline/nextjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Next.js library for Content Streamline API with reusable components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -49,4 +49,3 @@
|
|
|
49
49
|
"README.md"
|
|
50
50
|
]
|
|
51
51
|
}
|
|
52
|
-
|