@fullstackdatasolutions/articles 0.10.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
@@ -1,4 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentType } from 'react';
2
3
 
3
4
  interface TocItem {
4
5
  id: string;
@@ -135,6 +136,8 @@ interface HeroConfig {
135
136
  }
136
137
  /** Controls how article body links set target/rel attributes. */
137
138
  type LinkTargetStrategy = 'external-new-tab' | 'all-new-tab' | 'same-tab';
139
+ /** React components that article MDX bodies can reference by JSX tag name. */
140
+ type MdxComponents = Record<string, ComponentType<never>>;
138
141
  type ArticleBreadcrumbToken = 'home' | 'articles' | 'primaryCategory' | 'folderPath' | 'articleTitle';
139
142
  type CategoryBreadcrumbToken = 'home' | 'articles' | 'category';
140
143
  type AuthorBreadcrumbToken = 'home' | 'articles' | 'authors' | 'authorName';
@@ -213,6 +216,8 @@ interface ArticlesConfig {
213
216
  breadcrumbs?: false | BreadcrumbsConfig;
214
217
  /** Article body link target behavior. Default: `'external-new-tab'`. */
215
218
  linkTargetStrategy?: LinkTargetStrategy;
219
+ /** Extra components exposed to article MDX bodies by JSX tag name. */
220
+ mdxComponents?: MdxComponents;
216
221
  }
217
222
  declare const DEFAULT_PAGE_SIZE = 6;
218
223
  declare const DEFAULT_CATEGORIES_PAGE_SIZE = 8;
@@ -220,8 +225,10 @@ declare const DEFAULT_LAYOUT: ArticlesSection[];
220
225
  declare function breadcrumbsAreEnabled(config: ArticlesConfig): boolean;
221
226
  declare function getBreadcrumbsConfig(config: ArticlesConfig): BreadcrumbsConfig;
222
227
 
223
- declare function ArticlesPage({ config }: Readonly<{
228
+ declare function ArticlesPage({ config, initialArticles, initialCategories, }: Readonly<{
224
229
  config: ArticlesConfig;
230
+ initialArticles?: Article[];
231
+ initialCategories?: CategoryInfo[];
225
232
  }>): react_jsx_runtime.JSX.Element;
226
233
 
227
234
  type ArticleCardProps = Readonly<{
@@ -442,6 +449,6 @@ interface UseArticlesReturn {
442
449
  error: string | null;
443
450
  handleSearch: (query: string) => void;
444
451
  }
445
- declare function useArticles(): UseArticlesReturn;
452
+ declare function useArticles(initialArticles?: Article[], initialCategories?: CategoryInfo[]): UseArticlesReturn;
446
453
 
447
- 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, ScrollToTop, type TocItem, type UseArticlesReturn, breadcrumbsAreEnabled, getBreadcrumbsConfig, useArticles };
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
@@ -1,4 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentType } from 'react';
2
3
 
3
4
  interface TocItem {
4
5
  id: string;
@@ -135,6 +136,8 @@ interface HeroConfig {
135
136
  }
136
137
  /** Controls how article body links set target/rel attributes. */
137
138
  type LinkTargetStrategy = 'external-new-tab' | 'all-new-tab' | 'same-tab';
139
+ /** React components that article MDX bodies can reference by JSX tag name. */
140
+ type MdxComponents = Record<string, ComponentType<never>>;
138
141
  type ArticleBreadcrumbToken = 'home' | 'articles' | 'primaryCategory' | 'folderPath' | 'articleTitle';
139
142
  type CategoryBreadcrumbToken = 'home' | 'articles' | 'category';
140
143
  type AuthorBreadcrumbToken = 'home' | 'articles' | 'authors' | 'authorName';
@@ -213,6 +216,8 @@ interface ArticlesConfig {
213
216
  breadcrumbs?: false | BreadcrumbsConfig;
214
217
  /** Article body link target behavior. Default: `'external-new-tab'`. */
215
218
  linkTargetStrategy?: LinkTargetStrategy;
219
+ /** Extra components exposed to article MDX bodies by JSX tag name. */
220
+ mdxComponents?: MdxComponents;
216
221
  }
217
222
  declare const DEFAULT_PAGE_SIZE = 6;
218
223
  declare const DEFAULT_CATEGORIES_PAGE_SIZE = 8;
@@ -220,8 +225,10 @@ declare const DEFAULT_LAYOUT: ArticlesSection[];
220
225
  declare function breadcrumbsAreEnabled(config: ArticlesConfig): boolean;
221
226
  declare function getBreadcrumbsConfig(config: ArticlesConfig): BreadcrumbsConfig;
222
227
 
223
- declare function ArticlesPage({ config }: Readonly<{
228
+ declare function ArticlesPage({ config, initialArticles, initialCategories, }: Readonly<{
224
229
  config: ArticlesConfig;
230
+ initialArticles?: Article[];
231
+ initialCategories?: CategoryInfo[];
225
232
  }>): react_jsx_runtime.JSX.Element;
226
233
 
227
234
  type ArticleCardProps = Readonly<{
@@ -442,6 +449,6 @@ interface UseArticlesReturn {
442
449
  error: string | null;
443
450
  handleSearch: (query: string) => void;
444
451
  }
445
- declare function useArticles(): UseArticlesReturn;
452
+ declare function useArticles(initialArticles?: Article[], initialCategories?: CategoryInfo[]): UseArticlesReturn;
446
453
 
447
- 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, ScrollToTop, type TocItem, type UseArticlesReturn, breadcrumbsAreEnabled, getBreadcrumbsConfig, useArticles };
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;