@jjlmoya/utils-social 1.4.0 → 1.7.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": "@jjlmoya/utils-social",
3
- "version": "1.4.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { socialCategory } from './category';
2
- export { default as socialCategorySEO } from './category/seo.astro';
2
+ export const socialCategorySEO = () => import('./category/seo.astro').then((m) => m.default);
3
3
 
4
4
  export type {
5
5
  KnownLocale,
@@ -15,7 +15,7 @@ export type {
15
15
  ToolDefinition,
16
16
  } from './types';
17
17
 
18
- export { ALL_TOOLS } from './tools';
18
+ export { ALL_ENTRIES, ALL_TOOLS } from './tools';
19
19
 
20
20
  export { SafeZonesComponent, SafeZonesSEO, SafeZonesBibliography } from './tool/safeZones';
21
21
  export { YoutubeThumbnailComponent, YoutubeThumbnailSEO, YoutubeThumbnailBibliography } from './tool/youtubeThumbnail';
@@ -14,7 +14,8 @@ import type { UtilitySEOContent } from "@jjlmoya/utils-shared";
14
14
  export async function getStaticPaths() {
15
15
  const paths = [];
16
16
 
17
- for (const { entry, Component } of ALL_TOOLS) {
17
+ for (const { entry, Component: lazyComp } of ALL_TOOLS) {
18
+ const { default: Component } = await lazyComp();
18
19
  const localeEntries = Object.entries(entry.i18n) as [
19
20
  KnownLocale,
20
21
  () => Promise<ToolLocaleContent>,
@@ -52,8 +53,6 @@ export async function getStaticPaths() {
52
53
  return paths;
53
54
  }
54
55
 
55
- type ToolComponent = (props: { ui: Record<string, string> }) => unknown;
56
-
57
56
  interface NavItem {
58
57
  id: string;
59
58
  title: string;
@@ -62,7 +61,7 @@ interface NavItem {
62
61
  }
63
62
 
64
63
  interface Props {
65
- Component: ToolComponent;
64
+ Component: unknown;
66
65
  locale: KnownLocale;
67
66
  content: ToolLocaleContent;
68
67
  localeUrls: Partial<Record<KnownLocale, string>>;
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+ import type { ToolLocaleContent } from '../types';
4
+
5
+ describe('Slug Language Code Format Validation', () => {
6
+ const allowedLanguageSuffixes = ['-hd'];
7
+
8
+ ALL_TOOLS.forEach((tool) => {
9
+ describe(`Tool: ${tool.entry.id}`, () => {
10
+ it('slug should not end with 2-letter language codes like -ja, -ru, -ko', async () => {
11
+ const locales = Object.keys(tool.entry.i18n);
12
+
13
+ for (const locale of locales) {
14
+ const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
15
+ const content = (await loader?.()) as ToolLocaleContent;
16
+
17
+ const isAllowedException = allowedLanguageSuffixes.some((suffix) => content.slug.endsWith(suffix));
18
+
19
+ if (!isAllowedException) {
20
+ expect(
21
+ content.slug,
22
+ `Tool "${tool.entry.id}" locale "${locale}" slug ("${content.slug}") cannot end with a 2-letter language code (e.g., -ja, -ru, -ko).`,
23
+ ).not.toMatch(/-[a-z]{2}$/);
24
+ }
25
+ }
26
+ });
27
+ });
28
+ });
29
+ });
@@ -1,8 +1,5 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
2
 
3
- import RedditFormatterComponent from './component.astro';
4
- import RedditFormatterSEO from './seo.astro';
5
- import RedditFormatterBibliography from './bibliography.astro';
6
3
 
7
4
  import type { RedditFormatterUI } from './ui';
8
5
  export type RedditFormatterLocaleContent = ToolLocaleContent<RedditFormatterUI>;
@@ -32,11 +29,10 @@ export const redditFormatter: SocialToolEntry<RedditFormatterUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { RedditFormatterComponent, RedditFormatterSEO, RedditFormatterBibliography };
36
32
 
37
33
  export const REDDIT_FORMATTER_TOOL: ToolDefinition = {
38
34
  entry: redditFormatter,
39
- Component: RedditFormatterComponent,
40
- SEOComponent: RedditFormatterSEO,
41
- BibliographyComponent: RedditFormatterBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
@@ -1,7 +1,4 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import SafeZonesComponent from './component.astro';
3
- import SafeZonesSEO from './seo.astro';
4
- import SafeZonesBibliography from './bibliography.astro';
5
2
 
6
3
  import type { SafeZonesUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const safeZones: SocialToolEntry<SafeZonesUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { SafeZonesComponent, SafeZonesSEO, SafeZonesBibliography };
36
32
 
37
33
  export const SAFE_ZONES_TOOL: ToolDefinition = {
38
34
  entry: safeZones,
39
- Component: SafeZonesComponent,
40
- SEOComponent: SafeZonesSEO,
41
- BibliographyComponent: SafeZonesBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
@@ -1,8 +1,5 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
2
 
3
- import SocialImageResizerComponent from './component.astro';
4
- import SocialImageResizerSEO from './seo.astro';
5
- import SocialImageResizerBibliography from './bibliography.astro';
6
3
 
7
4
  import type { SocialImageResizerUI } from './ui';
8
5
  export type SocialImageResizerLocaleContent = ToolLocaleContent<SocialImageResizerUI>;
@@ -32,11 +29,10 @@ export const socialImageResizer: SocialToolEntry<SocialImageResizerUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { SocialImageResizerComponent, SocialImageResizerSEO, SocialImageResizerBibliography };
36
32
 
37
33
  export const SOCIAL_IMAGE_RESIZER_TOOL: ToolDefinition = {
38
34
  entry: socialImageResizer,
39
- Component: SocialImageResizerComponent,
40
- SEOComponent: SocialImageResizerSEO,
41
- BibliographyComponent: SocialImageResizerBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
@@ -1,8 +1,5 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
2
 
3
- import SocialValueCalculatorComponent from './component.astro';
4
- import SocialValueCalculatorSEO from './seo.astro';
5
- import SocialValueCalculatorBibliography from './bibliography.astro';
6
3
 
7
4
  import type { SocialValueCalculatorUI } from './ui';
8
5
  export type SocialValueCalculatorLocaleContent = ToolLocaleContent<SocialValueCalculatorUI>;
@@ -32,11 +29,10 @@ export const socialValueCalculator: SocialToolEntry<SocialValueCalculatorUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { SocialValueCalculatorComponent, SocialValueCalculatorSEO, SocialValueCalculatorBibliography };
36
32
 
37
33
  export const SOCIAL_VALUE_CALCULATOR_TOOL: ToolDefinition = {
38
34
  entry: socialValueCalculator,
39
- Component: SocialValueCalculatorComponent,
40
- SEOComponent: SocialValueCalculatorSEO,
41
- BibliographyComponent: SocialValueCalculatorBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
@@ -1,7 +1,4 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import TinderPhotoOptimizerComponent from './component.astro';
3
- import TinderPhotoOptimizerSEO from './seo.astro';
4
- import TinderPhotoOptimizerBibliography from './bibliography.astro';
5
2
 
6
3
  import type { TinderPhotoOptimizerUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const tinderPhotoOptimizer: SocialToolEntry<TinderPhotoOptimizerUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { TinderPhotoOptimizerComponent, TinderPhotoOptimizerSEO, TinderPhotoOptimizerBibliography };
36
32
 
37
33
  export const TINDER_PHOTO_OPTIMIZER_TOOL: ToolDefinition = {
38
34
  entry: tinderPhotoOptimizer,
39
- Component: TinderPhotoOptimizerComponent,
40
- SEOComponent: TinderPhotoOptimizerSEO,
41
- BibliographyComponent: TinderPhotoOptimizerBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
@@ -1,8 +1,5 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
2
 
3
- import YoutubeThumbnailComponent from './component.astro';
4
- import YoutubeThumbnailSEO from './seo.astro';
5
- import YoutubeThumbnailBibliography from './bibliography.astro';
6
3
 
7
4
  import type { YoutubeThumbnailUI } from './ui';
8
5
  export type YoutubeThumbnailLocaleContent = ToolLocaleContent<YoutubeThumbnailUI>;
@@ -32,11 +29,10 @@ export const youtubeThumbnail: SocialToolEntry<YoutubeThumbnailUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { YoutubeThumbnailComponent, YoutubeThumbnailSEO, YoutubeThumbnailBibliography };
36
32
 
37
33
  export const YOUTUBE_THUMBNAIL_TOOL: ToolDefinition = {
38
34
  entry: youtubeThumbnail,
39
- Component: YoutubeThumbnailComponent,
40
- SEOComponent: YoutubeThumbnailSEO,
41
- BibliographyComponent: YoutubeThumbnailBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
@@ -1,7 +1,4 @@
1
1
  import type { SocialToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import YoutubeThumbnailPreviewerComponent from './component.astro';
3
- import YoutubeThumbnailPreviewerSEO from './seo.astro';
4
- import YoutubeThumbnailPreviewerBibliography from './bibliography.astro';
5
2
 
6
3
  import type { YoutubeThumbnailPreviewerUI } from './ui';
7
4
 
@@ -48,11 +45,10 @@ export const youtubeThumbnailPreviewer: SocialToolEntry<YoutubeThumbnailPreviewe
48
45
  },
49
46
  };
50
47
 
51
- export { YoutubeThumbnailPreviewerComponent, YoutubeThumbnailPreviewerSEO, YoutubeThumbnailPreviewerBibliography };
52
48
 
53
49
  export const YOUTUBE_THUMBNAIL_PREVIEWER_TOOL: ToolDefinition = {
54
50
  entry: youtubeThumbnailPreviewer,
55
- Component: YoutubeThumbnailPreviewerComponent,
56
- SEOComponent: YoutubeThumbnailPreviewerSEO,
57
- BibliographyComponent: YoutubeThumbnailPreviewerBibliography,
51
+ Component: () => import('./component.astro'),
52
+ SEOComponent: () => import('./seo.astro'),
53
+ BibliographyComponent: () => import('./bibliography.astro'),
58
54
  };
package/src/tools.ts CHANGED
@@ -8,3 +8,5 @@ import { TINDER_PHOTO_OPTIMIZER_TOOL } from './tool/tinderPhotoOptimizer/index';
8
8
  import { YOUTUBE_THUMBNAIL_PREVIEWER_TOOL } from './tool/youtubeThumbnailPreviewer/index';
9
9
 
10
10
  export const ALL_TOOLS: ToolDefinition[] = [SAFE_ZONES_TOOL, YOUTUBE_THUMBNAIL_TOOL, SOCIAL_VALUE_CALCULATOR_TOOL, REDDIT_FORMATTER_TOOL, SOCIAL_IMAGE_RESIZER_TOOL, TINDER_PHOTO_OPTIMIZER_TOOL, YOUTUBE_THUMBNAIL_PREVIEWER_TOOL];
11
+
12
+ export const ALL_ENTRIES = ALL_TOOLS.map(t => t.entry);