@fullstackdatasolutions/articles 0.11.0 → 0.12.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/dist/index.d.cts CHANGED
@@ -225,8 +225,10 @@ declare const DEFAULT_LAYOUT: ArticlesSection[];
225
225
  declare function breadcrumbsAreEnabled(config: ArticlesConfig): boolean;
226
226
  declare function getBreadcrumbsConfig(config: ArticlesConfig): BreadcrumbsConfig;
227
227
 
228
- declare function ArticlesPage({ config }: Readonly<{
228
+ declare function ArticlesPage({ config, initialArticles, initialCategories, }: Readonly<{
229
229
  config: ArticlesConfig;
230
+ initialArticles?: Article[];
231
+ initialCategories?: CategoryInfo[];
230
232
  }>): react_jsx_runtime.JSX.Element;
231
233
 
232
234
  type ArticleCardProps = Readonly<{
@@ -447,6 +449,6 @@ interface UseArticlesReturn {
447
449
  error: string | null;
448
450
  handleSearch: (query: string) => void;
449
451
  }
450
- declare function useArticles(): UseArticlesReturn;
452
+ declare function useArticles(initialArticles?: Article[], initialCategories?: CategoryInfo[]): UseArticlesReturn;
451
453
 
452
454
  export { type Article, ArticleBackLink, type ArticleBreadcrumbEntry, type ArticleBreadcrumbToken, ArticleCard, ArticleCategoryGrid, type ArticleComment, type ArticleCommentWithReplies, ArticleDetailHero, ArticleNavigation, ArticleSEO, ArticleSchema, ArticleSearchBar, ArticleSocialShare, ArticleTOC, type ArticlesConfig, ArticlesHero, ArticlesPage, type ArticlesSection, type ArticlesTheme, AuthorArticlesPage, type AuthorBreadcrumbEntry, type AuthorBreadcrumbToken, AuthorCard, AuthorDetailHero, type AuthorProfile, type AuthorSocial, AuthorSocialLinks, Breadcrumb, type BreadcrumbItem, type BreadcrumbLabels, BreadcrumbSchema, type BreadcrumbsConfig, CategoryArticlesPage, type CategoryBreadcrumbEntry, type CategoryBreadcrumbToken, type CategoryDescription, type CategoryInfo, CollectionPageSchema, CommentForm, CommentItem, CommentThread, type CommentsConfig, CommentsSection, type CustomBreadcrumbItem, DEFAULT_CATEGORIES_PAGE_SIZE, DEFAULT_LAYOUT, DEFAULT_PAGE_SIZE, FAQPageSchema, type FaqItem, FeaturedArticle, type HowToStep, LatestArticles, LatestArticlesSection, type LinkTargetStrategy, type MdxComponents, ScrollToTop, type TocItem, type UseArticlesReturn, breadcrumbsAreEnabled, getBreadcrumbsConfig, useArticles };
package/dist/index.d.ts CHANGED
@@ -225,8 +225,10 @@ declare const DEFAULT_LAYOUT: ArticlesSection[];
225
225
  declare function breadcrumbsAreEnabled(config: ArticlesConfig): boolean;
226
226
  declare function getBreadcrumbsConfig(config: ArticlesConfig): BreadcrumbsConfig;
227
227
 
228
- declare function ArticlesPage({ config }: Readonly<{
228
+ declare function ArticlesPage({ config, initialArticles, initialCategories, }: Readonly<{
229
229
  config: ArticlesConfig;
230
+ initialArticles?: Article[];
231
+ initialCategories?: CategoryInfo[];
230
232
  }>): react_jsx_runtime.JSX.Element;
231
233
 
232
234
  type ArticleCardProps = Readonly<{
@@ -447,6 +449,6 @@ interface UseArticlesReturn {
447
449
  error: string | null;
448
450
  handleSearch: (query: string) => void;
449
451
  }
450
- declare function useArticles(): UseArticlesReturn;
452
+ declare function useArticles(initialArticles?: Article[], initialCategories?: CategoryInfo[]): UseArticlesReturn;
451
453
 
452
454
  export { type Article, ArticleBackLink, type ArticleBreadcrumbEntry, type ArticleBreadcrumbToken, ArticleCard, ArticleCategoryGrid, type ArticleComment, type ArticleCommentWithReplies, ArticleDetailHero, ArticleNavigation, ArticleSEO, ArticleSchema, ArticleSearchBar, ArticleSocialShare, ArticleTOC, type ArticlesConfig, ArticlesHero, ArticlesPage, type ArticlesSection, type ArticlesTheme, AuthorArticlesPage, type AuthorBreadcrumbEntry, type AuthorBreadcrumbToken, AuthorCard, AuthorDetailHero, type AuthorProfile, type AuthorSocial, AuthorSocialLinks, Breadcrumb, type BreadcrumbItem, type BreadcrumbLabels, BreadcrumbSchema, type BreadcrumbsConfig, CategoryArticlesPage, type CategoryBreadcrumbEntry, type CategoryBreadcrumbToken, type CategoryDescription, type CategoryInfo, CollectionPageSchema, CommentForm, CommentItem, CommentThread, type CommentsConfig, CommentsSection, type CustomBreadcrumbItem, DEFAULT_CATEGORIES_PAGE_SIZE, DEFAULT_LAYOUT, DEFAULT_PAGE_SIZE, FAQPageSchema, type FaqItem, FeaturedArticle, type HowToStep, LatestArticles, LatestArticlesSection, type LinkTargetStrategy, type MdxComponents, ScrollToTop, type TocItem, type UseArticlesReturn, breadcrumbsAreEnabled, getBreadcrumbsConfig, useArticles };
package/dist/index.js CHANGED
@@ -648,12 +648,12 @@ function getBreadcrumbsConfig(config) {
648
648
 
649
649
  // src/useArticles.ts
650
650
  import { useState as useState3, useCallback, useEffect as useEffect3, useRef } from "react";
651
- function useArticles() {
651
+ function useArticles(initialArticles, initialCategories) {
652
652
  const [searchQuery, setSearchQuery] = useState3("");
653
653
  const debounceRef = useRef(null);
654
- const [articles, setArticles] = useState3([]);
655
- const [categories, setCategories] = useState3([]);
656
- const [loading, setLoading] = useState3(true);
654
+ const [articles, setArticles] = useState3(initialArticles != null ? initialArticles : []);
655
+ const [categories, setCategories] = useState3(initialCategories != null ? initialCategories : []);
656
+ const [loading, setLoading] = useState3(initialArticles === void 0);
657
657
  const [error, setError] = useState3(null);
658
658
  const fetchArticles = useCallback((query) => __async(this, null, function* () {
659
659
  try {
@@ -691,7 +691,7 @@ function useArticles() {
691
691
  }
692
692
  }), []);
693
693
  useEffect3(() => {
694
- fetchArticles("");
694
+ if (initialArticles === void 0) fetchArticles("");
695
695
  }, [fetchArticles]);
696
696
  const handleSearch = useCallback(
697
697
  (query) => {
@@ -822,9 +822,13 @@ function renderSection(section, ctx, config) {
822
822
  return null;
823
823
  }
824
824
  }
825
- function ArticlesPage({ config }) {
825
+ function ArticlesPage({
826
+ config,
827
+ initialArticles,
828
+ initialCategories
829
+ }) {
826
830
  var _a, _b, _c;
827
- const state = useArticles();
831
+ const state = useArticles(initialArticles, initialCategories);
828
832
  const layout = (_a = config.layout) != null ? _a : DEFAULT_LAYOUT;
829
833
  const pageSize = (_b = config.pageSize) != null ? _b : DEFAULT_PAGE_SIZE;
830
834
  const categoriesPageSize = (_c = config.categoriesPageSize) != null ? _c : DEFAULT_CATEGORIES_PAGE_SIZE;