@se-studio/core-ui 1.0.45 → 1.0.46

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/README.md CHANGED
@@ -397,17 +397,12 @@ const previewConfig = mergeCmsRendererConfig(
397
397
  #### Utilities
398
398
  - **`buildPageMetadata`** - Generates Next.js metadata object from CMS page model
399
399
  - **`handleCmsError`** - Error handling utility for CMS operations
400
- - **`extractComponentInfo`** - Extract specific component information fields
401
- - **`extractCollectionInfo`** - Extract specific collection information fields
402
- - **`extractPageContext`** - Extract specific page context fields
400
+ - **`getRelatedArticles`** - Utility to fetch related articles for collections
401
+ - **`getRelatedPeople`** - Utility to fetch related people for collections
403
402
  - **`cn`** - Utility function for merging Tailwind CSS classes
404
403
 
405
404
  #### Types
406
405
  - **`CmsRendererConfig`** - Complete renderer configuration type
407
- - **`ComponentRenderer<T>`** - Type for component renderer functions
408
- - **`CollectionRenderer<T>`** - Type for collection renderer functions
409
- - **`ComponentConfig<T>`** - Type-safe component configuration
410
- - **`CollectionConfig<T>`** - Type-safe collection configuration
411
406
 
412
407
  For detailed JSDoc documentation on all exports, see the TypeScript declaration files (`.d.ts`) in the package.
413
408
 
@@ -417,7 +412,6 @@ For advanced CMS infrastructure usage, including:
417
412
  - Configuration composition patterns
418
413
  - Embeddable components
419
414
  - Context passing
420
- - Type-safe prop extraction
421
415
  - Preview mode setup
422
416
 
423
417
  See the [CMS Infrastructure Guide](./CMS_INFRASTRUCTURE.md).
package/dist/index.d.ts CHANGED
@@ -67,10 +67,9 @@ export { default as ResponsiveVisual } from './framework/ResponsiveVisual';
67
67
  export { useClickTracking } from './hooks/useClickTracking';
68
68
  export { RTF } from './rtf/rtf';
69
69
  export type { IBuildInformation } from './utils/buildPageMetadata';
70
- export { buildPageMetadata } from './utils/buildPageMetadata';
70
+ export { buildPageMetadata, calculateTitleAndDescription } from './utils/buildPageMetadata';
71
71
  export { cn } from './utils/cn';
72
- export type { ArrayToUnion, CollectionConfig, CollectionPropsFromConfig, ComponentConfig, ComponentPropsFromConfig, ContextPropsFromConfig, GeneratePropsFromCollectionConfig, GeneratePropsFromComponentConfig, } from './utils/componentUtils';
73
- export { createCollectionProps, createComponentProps, extractCollectionInfo, extractComponentInfo, extractPageContext, } from './utils/componentUtils';
72
+ export { getRelatedArticles, getRelatedPeople, } from './utils/componentUtils';
74
73
  export { convertText } from './utils/convertText';
75
74
  export { handleCmsError } from './utils/errorHandling';
76
75
  export { captureException, initErrorMonitoring } from './utils/errorMonitoring';
@@ -84,7 +83,7 @@ export type { StructuredDataConfig, StructuredDataContext } from './utils/struct
84
83
  export { buildStructuredDataContext } from './utils/structuredDataUtils';
85
84
  export { UnsupportedWarning } from './utils/UnsupportedWarning';
86
85
  export { DEFAULT_ALLOWED_UNUSED, UnusedChecker } from './utils/UnusedChecker';
87
- export { isAbsoluteUrl } from './utils/urlUtils';
86
+ export { getCurrentPageUrl, isAbsoluteUrl } from './utils/urlUtils';
88
87
  export { calculateHorizontalPositionClassName } from './utils/visualPositions';
89
88
  export { calculateVisualSizes } from './utils/visualSizes';
90
89
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,+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E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -66,10 +66,10 @@ export { default as ResponsiveVisual } from './framework/ResponsiveVisual';
66
66
  // Shared Hooks
67
67
  export { useClickTracking } from './hooks/useClickTracking';
68
68
  export { RTF } from './rtf/rtf';
69
- export { buildPageMetadata } from './utils/buildPageMetadata';
69
+ export { buildPageMetadata, calculateTitleAndDescription } from './utils/buildPageMetadata';
70
70
  // Shared Utilities
71
71
  export { cn } from './utils/cn';
72
- export { createCollectionProps, createComponentProps, extractCollectionInfo, extractComponentInfo, extractPageContext, } from './utils/componentUtils';
72
+ export { getRelatedArticles, getRelatedPeople, } from './utils/componentUtils';
73
73
  export { convertText } from './utils/convertText';
74
74
  export { handleCmsError } from './utils/errorHandling';
75
75
  export { captureException, initErrorMonitoring } from './utils/errorMonitoring';
@@ -80,7 +80,7 @@ export { buildStructuredDataContext } from './utils/structuredDataUtils';
80
80
  export { UnsupportedWarning } from './utils/UnsupportedWarning';
81
81
  // Development Utilities
82
82
  export { DEFAULT_ALLOWED_UNUSED, UnusedChecker } from './utils/UnusedChecker';
83
- export { isAbsoluteUrl } from './utils/urlUtils';
83
+ export { getCurrentPageUrl, isAbsoluteUrl } from './utils/urlUtils';
84
84
  export { calculateHorizontalPositionClassName } from './utils/visualPositions';
85
85
  export { calculateVisualSizes } from './utils/visualSizes';
86
86
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;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OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { IBaseModel } from '@se-studio/core-data-types';
1
+ import type { IBaseArticle, IBaseArticleType, IBaseCustomType, IBaseModel, IBaseTag } from '@se-studio/core-data-types';
2
2
  import type { Metadata, ResolvingMetadata } from 'next';
3
3
  /**
4
4
  * Configuration for building page metadata.
@@ -57,4 +57,23 @@ export interface IBuildInformation {
57
57
  * ```
58
58
  */
59
59
  export declare function buildPageMetadata(model: Pick<IBaseModel, 'title' | 'description' | 'featuredImage' | 'indexed'>, path: string, { baseUrl, isProduction, customerName, applicationName }: IBuildInformation, _parent: ResolvingMetadata): Metadata;
60
+ /**
61
+ * Utility function to calculate title and description for various content types.
62
+ *
63
+ * This provides a standard way to generate SEO text for resource index pages,
64
+ * topic pages, and individual articles. Projects can use this in their
65
+ * metadata generation logic.
66
+ *
67
+ * @param params - Objects representing the context (article, tag, articleType, customType)
68
+ * @returns Object with title and description strings
69
+ */
70
+ export declare function calculateTitleAndDescription({ articleType, customType, tag, article, }: {
71
+ articleType?: IBaseArticleType;
72
+ customType?: IBaseCustomType;
73
+ tag?: IBaseTag;
74
+ article?: IBaseArticle;
75
+ }): {
76
+ title: string;
77
+ description: string;
78
+ };
60
79
  //# sourceMappingURL=buildPageMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildPageMetadata.d.ts","sourceRoot":"","sources":["../../src/utils/buildPageMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,YAAY,EAAE,OAAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,aAAa,GAAG,eAAe,GAAG,SAAS,CAAC,EAC9E,IAAI,EAAE,MAAM,EACZ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,EAAE,iBAAiB,EAC3E,OAAO,EAAE,iBAAiB,GACzB,QAAQ,CA8CV;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,WAAW,EACX,UAAU,EACV,GAAG,EACH,OAAO,GACR,EAAE;IACD,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;;;EA0BA"}
@@ -79,4 +79,41 @@ export function buildPageMetadata(model, path, { baseUrl, isProduction, customer
79
79
  };
80
80
  return result;
81
81
  }
82
+ /**
83
+ * Utility function to calculate title and description for various content types.
84
+ *
85
+ * This provides a standard way to generate SEO text for resource index pages,
86
+ * topic pages, and individual articles. Projects can use this in their
87
+ * metadata generation logic.
88
+ *
89
+ * @param params - Objects representing the context (article, tag, articleType, customType)
90
+ * @returns Object with title and description strings
91
+ */
92
+ export function calculateTitleAndDescription({ articleType, customType, tag, article, }) {
93
+ if (article) {
94
+ return { title: article.title, description: article.description };
95
+ }
96
+ if (tag && articleType) {
97
+ return {
98
+ title: `${tag.title}`,
99
+ description: `Browse the latest ${articleType.name.toLowerCase()} resources related to ${tag.name.toLowerCase()}.`,
100
+ };
101
+ }
102
+ if (tag && customType) {
103
+ return {
104
+ title: `${tag.title}`,
105
+ description: `Browse the latest ${customType.name.toLowerCase()} resources related to ${tag.name.toLowerCase()}.`,
106
+ };
107
+ }
108
+ if (tag) {
109
+ return { title: tag.title, description: tag.description };
110
+ }
111
+ if (articleType) {
112
+ return { title: articleType.title, description: articleType.description };
113
+ }
114
+ if (customType) {
115
+ return { title: customType.title, description: customType.description };
116
+ }
117
+ return { title: '', description: '' };
118
+ }
82
119
  //# sourceMappingURL=buildPageMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildPageMetadata.js","sourceRoot":"","sources":["../../src/utils/buildPageMetadata.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA8E,EAC9E,IAAY,EACZ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAqB,EAC3E,OAA0B;IAE1B,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC3E,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;IAEpD,MAAM,eAAe,GAAG,aAAa,EAAE,EAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,OAAO,eAAe,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAErF,MAAM,MAAM,GAAa;QACvB,YAAY,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC;QAC9B,eAAe,EAAE,eAAe,IAAI,YAAY;QAChD,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE;YACpC,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,uBAAuB,EAAE;SACzD;QACD,WAAW,EAAE;YACX,KAAK,EAAE,eAAe,IAAI,YAAY;SACvC;QACD,UAAU,EAAE;YACV,SAAS,EAAE,IAAI;SAChB;QACD,MAAM,EAAE;YACN,KAAK,EAAE,OAAO,IAAI,KAAK;YACvB,MAAM,EAAE,OAAO,IAAI,KAAK;SACzB;QACD,KAAK;QACL,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,EAAE,GAAG,GAAG,CAAC,KAAK,EAAE;YACrB,WAAW,EAAE,qBAAqB,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,yBAAyB,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG;SAClH,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,CAAC;IAC5E,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;IAC1E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AACxC,CAAC"}
@@ -1,147 +1,40 @@
1
- import type { IBaseCollection, IBaseComponent, IPageContext } from '@se-studio/core-data-types';
2
- import type React from 'react';
3
- export type ArrayToUnion<T extends ReadonlyArray<unknown>> = T[number];
4
- /**
5
- * Since we've moved to non-generic base types, component utilities now work
6
- * with the base types directly. Projects can extend these base types with
7
- * additional properties and use type assertions at the component level.
8
- */
9
- export interface ComponentConfig<TAdditional = Record<string, unknown>> {
10
- componentProps: ReadonlyArray<keyof IBaseComponent>;
11
- contextProps: ReadonlyArray<keyof IPageContext>;
12
- additionalProps?: TAdditional;
13
- }
14
- export interface CollectionConfig<TAdditional = Record<string, unknown>> {
15
- collectionProps: ReadonlyArray<keyof IBaseCollection>;
16
- contextProps: ReadonlyArray<keyof IPageContext>;
17
- additionalProps?: TAdditional;
18
- }
19
- export type ComponentPropsFromConfig<T extends ComponentConfig> = T['componentProps'] extends ReadonlyArray<keyof IBaseComponent> ? Pick<IBaseComponent, ArrayToUnion<T['componentProps']>> : never;
20
- export type CollectionPropsFromConfig<T extends CollectionConfig> = T['collectionProps'] extends ReadonlyArray<keyof IBaseCollection> ? Pick<IBaseCollection, ArrayToUnion<T['collectionProps']>> : never;
21
- export type ContextPropsFromConfig<T extends ComponentConfig | CollectionConfig> = Pick<IPageContext, ArrayToUnion<T['contextProps']>>;
22
- export type GeneratePropsFromComponentConfig<T extends ComponentConfig> = ComponentPropsFromConfig<T> & ContextPropsFromConfig<T> & (T['additionalProps'] extends Record<string, unknown> ? T['additionalProps'] : Record<string, never>);
23
- export type GeneratePropsFromCollectionConfig<T extends CollectionConfig> = CollectionPropsFromConfig<T> & ContextPropsFromConfig<T> & (T['additionalProps'] extends Record<string, unknown> ? T['additionalProps'] : Record<string, never>);
24
- /**
25
- * Extract specific component information fields that a component needs.
26
- * This is used when you only need a subset of the component fields.
27
- *
28
- * @param information - The full component information object
29
- * @param keys - Array of keys to extract from the information object
30
- * @returns Object with only the specified keys
31
- *
32
- * @example
33
- * ```tsx
34
- * const props = extractComponentInfo(information, ['heading', 'body', 'links']);
35
- * // props will have type { heading?: string | null, body?: unknown, links?: ReadonlyArray<ILinkProps> }
36
- * ```
37
- */
38
- export declare function extractComponentInfo<K extends keyof IBaseComponent>(information: IBaseComponent, keys: ReadonlyArray<K>): Pick<IBaseComponent, K>;
39
- /**
40
- * Extract specific collection information fields that a collection needs.
41
- * This is used when you only need a subset of the collection fields.
42
- *
43
- * @param information - The full collection information object
44
- * @param keys - Array of keys to extract from the information object
45
- * @returns Object with only the specified keys
46
- *
47
- * @example
48
- * ```tsx
49
- * const props = extractCollectionInfo(information, ['heading', 'body', 'contents']);
50
- * // props will have type { heading?: string | null, body?: unknown, contents?: ReadonlyArray<CollectionContent> }
51
- * ```
52
- */
53
- export declare function extractCollectionInfo<K extends keyof IBaseCollection>(information: IBaseCollection, keys: ReadonlyArray<K>): Pick<IBaseCollection, K>;
54
- /**
55
- * Extract specific page context fields that a component needs.
56
- *
57
- * @param pageContext - The full page context object
58
- * @param keys - Array of keys to extract from the page context
59
- * @returns Object with only the specified keys
60
- *
61
- * @example
62
- * ```tsx
63
- * const contextProps = extractPageContext(pageContext, ['articleLink', 'pageLink']);
64
- * ```
65
- */
66
- export declare function extractPageContext<K extends keyof IPageContext>(pageContext: IPageContext, keys: ReadonlyArray<K>): Pick<IPageContext, K>;
67
- /**
68
- * Helper type to create a component renderer function with specific prop requirements.
69
- * This provides better type safety when defining component renderers.
70
- *
71
- * @example
72
- * ```tsx
73
- * const config = {
74
- * componentProps: ['heading', 'body', 'links'],
75
- * contextProps: ['pageLink'],
76
- * additionalProps: { theme: 'dark' as const }
77
- * } as const satisfies ComponentConfig;
78
- *
79
- * const MyComponent: ComponentRenderer<typeof config> = ({ heading, body, links, pageLink, theme }) => {
80
- * // All props are properly typed
81
- * return <div>{heading}</div>;
82
- * };
83
- * ```
84
- */
85
- export type ComponentRenderer<T extends ComponentConfig> = (props: GeneratePropsFromComponentConfig<T>) => React.ReactElement | null;
86
- /**
87
- * Helper type to create a collection renderer function with specific prop requirements.
88
- * This provides better type safety when defining collection renderers.
89
- *
90
- * @example
91
- * ```tsx
92
- * const config = {
93
- * collectionProps: ['heading', 'body', 'contents'],
94
- * contextProps: ['articleLink'],
95
- * additionalProps: { layout: 'grid' as const }
96
- * } as const satisfies CollectionConfig;
97
- *
98
- * const MyCollection: CollectionRenderer<typeof config> = ({ heading, body, contents, articleLink, layout }) => {
99
- * // All props are properly typed
100
- * return <div>{heading}</div>;
101
- * };
102
- * ```
103
- */
104
- export type CollectionRenderer<T extends CollectionConfig> = (props: GeneratePropsFromCollectionConfig<T>) => React.ReactElement | null;
105
- /**
106
- * Create props object for a component renderer from component information and page context.
107
- * This function extracts the specified fields and combines them with additional props.
108
- *
109
- * @param config - Configuration specifying which props to extract
110
- * @param information - The component information object
111
- * @param pageContext - The page context object
112
- * @param additionalProps - Additional props to include (optional)
113
- * @returns Combined props object ready to pass to the component
114
- *
115
- * @example
116
- * ```tsx
117
- * const config = {
118
- * componentProps: ['heading', 'body'],
119
- * contextProps: ['pageLink'],
120
- * } as const;
121
- *
122
- * const props = createComponentProps(config, information, pageContext);
123
- * ```
124
- */
125
- export declare function createComponentProps<T extends ComponentConfig>(config: T, information: IBaseComponent, pageContext: IPageContext, additionalProps?: T['additionalProps']): GeneratePropsFromComponentConfig<T>;
126
- /**
127
- * Create props object for a collection renderer from collection information and page context.
128
- * This function extracts the specified fields and combines them with additional props.
129
- *
130
- * @param config - Configuration specifying which props to extract
131
- * @param information - The collection information object
132
- * @param pageContext - The page context object
133
- * @param additionalProps - Additional props to include (optional)
134
- * @returns Combined props object ready to pass to the collection
135
- *
136
- * @example
137
- * ```tsx
138
- * const config = {
139
- * collectionProps: ['heading', 'contents'],
140
- * contextProps: ['articleLink'],
141
- * } as const;
142
- *
143
- * const props = createCollectionProps(config, information, pageContext);
144
- * ```
145
- */
146
- export declare function createCollectionProps<T extends CollectionConfig>(config: T, information: IBaseCollection, pageContext: IPageContext, additionalProps?: T['additionalProps']): GeneratePropsFromCollectionConfig<T>;
1
+ import { type BaseConverterContext, type ContentfulConfig, type FetchOptions, type IContentfulCollection } from '@se-studio/contentful-rest-api';
2
+ import { type BaseCollectionContent, type IArticleLink, type IContentContext, type IPersonLink } from '@se-studio/core-data-types';
3
+ /**
4
+ * Generic helper to get related articles for a collection.
5
+ *
6
+ * This function orchestrates the fetching of related articles by:
7
+ * 1. Extracting hard-coded articles from collection contents
8
+ * 2. Extracting filter criteria from collection links (tags, article type)
9
+ * 3. Extracting fallback criteria from page context (article type, current article)
10
+ * 4. Fetching additional articles if needed to reach the requested count
11
+ * 5. Returning manual articles followed by fetched articles
12
+ *
13
+ * @param information - The collection information containing contents and links
14
+ * @param contentContext - The content context containing page context
15
+ * @param converterContext - The project-specific converter context (contains URL rules)
16
+ * @param config - Contentful configuration
17
+ * @param count - Maximum number of articles to return (optional)
18
+ * @param options - Optional fetch options for preview mode and caching
19
+ * @returns Array of article links (manual articles first, then fetched)
20
+ */
21
+ export declare function getRelatedArticles<T extends BaseCollectionContent>(information: IContentfulCollection<T>, contentContext: IContentContext, converterContext: BaseConverterContext, config: ContentfulConfig, count: number | undefined, options: FetchOptions): Promise<IArticleLink[]>;
22
+ /**
23
+ * Generic helper to get related people for a collection.
24
+ *
25
+ * This function orchestrates the fetching of related people by:
26
+ * 1. Extracting hard-coded people from collection contents
27
+ * 2. Fetching additional people if needed to reach the requested count
28
+ * 3. Excluding the current person (if on a person page) and manually added people
29
+ * 4. Returning manual people followed by fetched people
30
+ *
31
+ * @param information - The collection information containing contents
32
+ * @param contentContext - The content context containing page context
33
+ * @param converterContext - The project-specific converter context
34
+ * @param config - Contentful configuration
35
+ * @param count - Maximum number of people to return (default: 4)
36
+ * @param options - Optional fetch options for preview mode and caching
37
+ * @returns Array of person links (manual people first, then fetched)
38
+ */
39
+ export declare function getRelatedPeople<T extends BaseCollectionContent>(information: IContentfulCollection<T>, contentContext: IContentContext, converterContext: BaseConverterContext, config: ContentfulConfig, count: number, options: FetchOptions): Promise<IPersonLink[]>;
147
40
  //# sourceMappingURL=componentUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"componentUtils.d.ts","sourceRoot":"","sources":["../../src/utils/componentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE;;;;GAIG;AAGH,MAAM,WAAW,eAAe,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEpE,cAAc,EAAE,aAAa,CAAC,MAAM,cAAc,CAAC,CAAC;IAEpD,YAAY,EAAE,aAAa,CAAC,MAAM,YAAY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AM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,EAAE,CAAC,CAmCxB"}
@@ -1,126 +1,167 @@
1
+ import { contentfulAllArticleLinks, contentfulAllPersonLinks, filterRelatedArticles, } from '@se-studio/contentful-rest-api';
2
+ import { isArticleLink, isArticleTypeLink, isPersonLink, isTagLink, } from '@se-studio/core-data-types';
1
3
  /**
2
- * Extract specific component information fields that a component needs.
3
- * This is used when you only need a subset of the component fields.
4
- *
5
- * @param information - The full component information object
6
- * @param keys - Array of keys to extract from the information object
7
- * @returns Object with only the specified keys
8
- *
9
- * @example
10
- * ```tsx
11
- * const props = extractComponentInfo(information, ['heading', 'body', 'links']);
12
- * // props will have type { heading?: string | null, body?: unknown, links?: ReadonlyArray<ILinkProps> }
13
- * ```
4
+ * Extract filter criteria (article types, tags, authors) from collection links.
5
+ * Internal helper for getRelatedArticles.
14
6
  */
15
- export function extractComponentInfo(information, keys) {
16
- const result = {};
17
- for (const key of keys) {
18
- if (key in information) {
19
- result[key] = information[key];
7
+ function extractFilterCriteria(links) {
8
+ const articleTypeIds = [];
9
+ const tagIds = [];
10
+ const authorIds = [];
11
+ if (links) {
12
+ for (const link of links) {
13
+ if (isArticleTypeLink(link)) {
14
+ articleTypeIds.push(link.id);
15
+ }
16
+ else if (isTagLink(link)) {
17
+ tagIds.push(link.id);
18
+ }
19
+ else if (isPersonLink(link)) {
20
+ authorIds.push(link.id);
21
+ }
20
22
  }
21
23
  }
22
- return result;
24
+ return { articleTypeIds, tagIds, authorIds };
23
25
  }
24
26
  /**
25
- * Extract specific collection information fields that a collection needs.
26
- * This is used when you only need a subset of the collection fields.
27
- *
28
- * @param information - The full collection information object
29
- * @param keys - Array of keys to extract from the information object
30
- * @returns Object with only the specified keys
31
- *
32
- * @example
33
- * ```tsx
34
- * const props = extractCollectionInfo(information, ['heading', 'body', 'contents']);
35
- * // props will have type { heading?: string | null, body?: unknown, contents?: ReadonlyArray<CollectionContent> }
36
- * ```
27
+ * Apply fallback criteria from page context when no explicit criteria provided.
28
+ * Internal helper for getRelatedArticles.
37
29
  */
38
- export function extractCollectionInfo(information, keys) {
39
- const result = {};
40
- for (const key of keys) {
41
- if (key in information) {
42
- result[key] = information[key];
30
+ function applyFallbackCriteria(criteria, contentContext) {
31
+ if (criteria.articleTypeIds.length === 0) {
32
+ const articleType = contentContext.pageContext?.articleType;
33
+ if (articleType) {
34
+ criteria.articleTypeIds.push(articleType.id);
35
+ }
36
+ else {
37
+ const article = contentContext.pageContext?.article;
38
+ if (article?.articleType?.id) {
39
+ criteria.articleTypeIds.push(article.articleType.id);
40
+ }
41
+ }
42
+ }
43
+ if (criteria.authorIds.length === 0) {
44
+ const person = contentContext.pageContext?.person;
45
+ if (person) {
46
+ criteria.authorIds.push(person.id);
43
47
  }
44
48
  }
45
- return result;
46
49
  }
47
50
  /**
48
- * Extract specific page context fields that a component needs.
49
- *
50
- * @param pageContext - The full page context object
51
- * @param keys - Array of keys to extract from the page context
52
- * @returns Object with only the specified keys
53
- *
54
- * @example
55
- * ```tsx
56
- * const contextProps = extractPageContext(pageContext, ['articleLink', 'pageLink']);
57
- * ```
51
+ * Determine whether we should fetch additional articles.
52
+ * Internal helper for getRelatedArticles.
58
53
  */
59
- export function extractPageContext(pageContext, keys) {
60
- const result = {};
61
- for (const key of keys) {
62
- if (key in pageContext) {
63
- result[key] = pageContext[key];
64
- }
54
+ function shouldFetchArticles(isAll, remainingSlots, criteria) {
55
+ if (isAll) {
56
+ return true;
65
57
  }
66
- return result;
58
+ const hasSlots = remainingSlots !== undefined && remainingSlots > 0;
59
+ const hasFilters = criteria.articleTypeIds.length > 0 ||
60
+ criteria.tagIds.length > 0 ||
61
+ criteria.authorIds.length > 0;
62
+ return hasSlots && hasFilters;
67
63
  }
68
64
  /**
69
- * Create props object for a component renderer from component information and page context.
70
- * This function extracts the specified fields and combines them with additional props.
65
+ * Generic helper to get related articles for a collection.
71
66
  *
72
- * @param config - Configuration specifying which props to extract
73
- * @param information - The component information object
74
- * @param pageContext - The page context object
75
- * @param additionalProps - Additional props to include (optional)
76
- * @returns Combined props object ready to pass to the component
67
+ * This function orchestrates the fetching of related articles by:
68
+ * 1. Extracting hard-coded articles from collection contents
69
+ * 2. Extracting filter criteria from collection links (tags, article type)
70
+ * 3. Extracting fallback criteria from page context (article type, current article)
71
+ * 4. Fetching additional articles if needed to reach the requested count
72
+ * 5. Returning manual articles followed by fetched articles
77
73
  *
78
- * @example
79
- * ```tsx
80
- * const config = {
81
- * componentProps: ['heading', 'body'],
82
- * contextProps: ['pageLink'],
83
- * } as const;
84
- *
85
- * const props = createComponentProps(config, information, pageContext);
86
- * ```
74
+ * @param information - The collection information containing contents and links
75
+ * @param contentContext - The content context containing page context
76
+ * @param converterContext - The project-specific converter context (contains URL rules)
77
+ * @param config - Contentful configuration
78
+ * @param count - Maximum number of articles to return (optional)
79
+ * @param options - Optional fetch options for preview mode and caching
80
+ * @returns Array of article links (manual articles first, then fetched)
87
81
  */
88
- export function createComponentProps(config, information, pageContext, additionalProps) {
89
- const componentProps = extractComponentInfo(information, config.componentProps);
90
- const contextProps = extractPageContext(pageContext, config.contextProps);
91
- return {
92
- ...componentProps,
93
- ...contextProps,
94
- ...(additionalProps ?? {}),
95
- };
82
+ export async function getRelatedArticles(information, contentContext, converterContext, config, count, options) {
83
+ const isAll = typeof count === 'undefined';
84
+ // Step 1: Extract hard-coded articles from contents
85
+ const manualArticles = information.contents?.filter((item) => isArticleLink(item)) ?? [];
86
+ // Early return if we have enough manual articles
87
+ if (!isAll && count !== undefined && manualArticles.length >= count) {
88
+ return manualArticles.slice(0, count);
89
+ }
90
+ // Step 2: Extract and apply filter criteria
91
+ const criteria = extractFilterCriteria(information.links);
92
+ applyFallbackCriteria(criteria, contentContext);
93
+ // Step 3: Build exclusion list
94
+ const currentArticle = contentContext.pageContext?.article;
95
+ const excludeArticleIds = [
96
+ ...manualArticles.map((article) => article.id),
97
+ ...(currentArticle ? [currentArticle.id] : []),
98
+ ];
99
+ // Step 4: Fetch additional articles if needed
100
+ const remainingSlots = isAll || count === undefined ? undefined : count - manualArticles.length;
101
+ let fetchedArticles = [];
102
+ if (shouldFetchArticles(isAll, remainingSlots, criteria)) {
103
+ try {
104
+ const response = await contentfulAllArticleLinks(converterContext, config, options);
105
+ const filterOptions = {
106
+ excludeArticleIds,
107
+ tagIds: criteria.tagIds,
108
+ articleTypeIds: criteria.articleTypeIds,
109
+ authorIds: criteria.authorIds,
110
+ count: remainingSlots,
111
+ };
112
+ fetchedArticles = filterRelatedArticles(response.data, filterOptions);
113
+ }
114
+ catch (error) {
115
+ console.error('[getRelatedArticles] Error fetching articles:', error);
116
+ }
117
+ }
118
+ // Step 5: Return manual articles followed by fetched articles
119
+ return [...manualArticles, ...fetchedArticles].slice(0, count);
96
120
  }
97
121
  /**
98
- * Create props object for a collection renderer from collection information and page context.
99
- * This function extracts the specified fields and combines them with additional props.
122
+ * Generic helper to get related people for a collection.
100
123
  *
101
- * @param config - Configuration specifying which props to extract
102
- * @param information - The collection information object
103
- * @param pageContext - The page context object
104
- * @param additionalProps - Additional props to include (optional)
105
- * @returns Combined props object ready to pass to the collection
124
+ * This function orchestrates the fetching of related people by:
125
+ * 1. Extracting hard-coded people from collection contents
126
+ * 2. Fetching additional people if needed to reach the requested count
127
+ * 3. Excluding the current person (if on a person page) and manually added people
128
+ * 4. Returning manual people followed by fetched people
106
129
  *
107
- * @example
108
- * ```tsx
109
- * const config = {
110
- * collectionProps: ['heading', 'contents'],
111
- * contextProps: ['articleLink'],
112
- * } as const;
113
- *
114
- * const props = createCollectionProps(config, information, pageContext);
115
- * ```
130
+ * @param information - The collection information containing contents
131
+ * @param contentContext - The content context containing page context
132
+ * @param converterContext - The project-specific converter context
133
+ * @param config - Contentful configuration
134
+ * @param count - Maximum number of people to return (default: 4)
135
+ * @param options - Optional fetch options for preview mode and caching
136
+ * @returns Array of person links (manual people first, then fetched)
116
137
  */
117
- export function createCollectionProps(config, information, pageContext, additionalProps) {
118
- const collectionProps = extractCollectionInfo(information, config.collectionProps);
119
- const contextProps = extractPageContext(pageContext, config.contextProps);
120
- return {
121
- ...collectionProps,
122
- ...contextProps,
123
- ...(additionalProps ?? {}),
124
- };
138
+ export async function getRelatedPeople(information, contentContext, converterContext, config, count, options) {
139
+ // Step 1: Extract hard-coded people from contents
140
+ const manualPeople = information.contents?.filter((item) => isPersonLink(item)) ?? [];
141
+ // Early return if we have enough manual people
142
+ if (manualPeople.length >= count) {
143
+ return manualPeople.slice(0, count);
144
+ }
145
+ // Step 2: Build exclusion list
146
+ const currentPerson = contentContext.pageContext?.person;
147
+ const excludePersonIds = new Set([
148
+ ...manualPeople.map((person) => person.id),
149
+ ...(currentPerson ? [currentPerson.id] : []),
150
+ ]);
151
+ // Step 3: Fetch additional people if needed
152
+ const remainingSlots = count - manualPeople.length;
153
+ let fetchedPeople = [];
154
+ try {
155
+ const response = await contentfulAllPersonLinks(converterContext, config, options);
156
+ // Filter out excluded people
157
+ fetchedPeople = response.data
158
+ .filter((person) => isPersonLink(person) && !excludePersonIds.has(person.id))
159
+ .slice(0, remainingSlots);
160
+ }
161
+ catch (error) {
162
+ console.error('[getRelatedPeople] Error fetching people:', error);
163
+ }
164
+ // Step 4: Return manual people followed by fetched people
165
+ return [...manualPeople, ...fetchedPeople].slice(0, count);
125
166
  }
126
167
  //# sourceMappingURL=componentUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"componentUtils.js","sourceRoot":"","sources":["../../src/utils/componentUtils.ts"],"names":[],"mappings":"AAkEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAA2B,EAC3B,IAAsB;IAEtB,MAAM,MAAM,GAAG,EAA6B,CAAC;IAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,G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G,CAAC;QAC/B,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAC,CAAC;IAEH,4CAA4C;IAC5C,MAAM,cAAc,GAAG,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC;IACnD,IAAI,aAAa,GAAkB,EAAE,CAAC;IAEtC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAEnF,6BAA6B;QAC7B,aAAa,GAAG,QAAQ,CAAC,IAAI;aAC1B,MAAM,CACL,CAAC,MAAM,EAAyB,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAC5F;aACA,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,0DAA0D;IAC1D,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,2 +1,7 @@
1
1
  export declare function isAbsoluteUrl(url: string): boolean;
2
+ /**
3
+ * Utility function to get the current page URL safely.
4
+ * Returns an empty string when running on the server.
5
+ */
6
+ export declare function getCurrentPageUrl(): string;
2
7
  //# sourceMappingURL=urlUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/urlUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOlD"}
1
+ {"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/urlUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOlD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C"}
@@ -7,4 +7,14 @@ export function isAbsoluteUrl(url) {
7
7
  return false;
8
8
  }
9
9
  }
10
+ /**
11
+ * Utility function to get the current page URL safely.
12
+ * Returns an empty string when running on the server.
13
+ */
14
+ export function getCurrentPageUrl() {
15
+ if (typeof window !== 'undefined') {
16
+ return window.location.href;
17
+ }
18
+ return '';
19
+ }
10
20
  //# sourceMappingURL=urlUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../../src/utils/urlUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../../src/utils/urlUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/core-ui",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "Shared React UI component library with Tailwind CSS v4 for SE Studio applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -58,8 +58,8 @@
58
58
  "html-entities": "^2.6.0",
59
59
  "mustache": "4.2.0",
60
60
  "tailwind-merge": "^3.4.0",
61
- "@se-studio/contentful-rest-api": "1.0.45",
62
- "@se-studio/core-data-types": "1.0.45"
61
+ "@se-studio/contentful-rest-api": "1.0.46",
62
+ "@se-studio/core-data-types": "1.0.46"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@biomejs/biome": "^2.3.10",
@@ -69,7 +69,7 @@
69
69
  "@types/react": "^19.2.7",
70
70
  "@types/react-dom": "^19.2.3",
71
71
  "@vitejs/plugin-react": "^5.1.2",
72
- "jsdom": "^27.3.0",
72
+ "jsdom": "^27.4.0",
73
73
  "next": "^15.5.9",
74
74
  "typescript": "^5.9.3",
75
75
  "vitest": "^4.0.16"