@jjlmoya/utils-textiles 1.5.0 → 1.8.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-textiles",
3
- "version": "1.5.0",
3
+ "version": "1.8.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 { textilesCategory } from './category';
2
- export { default as textilesCategorySEO } from './category/seo.astro';
2
+ export const textilesCategorySEO = () => import('./category/seo.astro').then((m) => m.default);
3
3
 
4
4
  export { FabricTruthComponent, FabricTruthSEO, FabricTruthBibliography, FABRIC_TRUTH_TOOL } from './tool/fabricTruth';
5
5
  export { LaundryGuideComponent, LaundryGuideSEO, LaundryGuideBibliography, LAUNDRY_GUIDE_TOOL } from './tool/laundryGuide';
@@ -28,5 +28,5 @@ export type {
28
28
  ToolDefinition,
29
29
  } from './types';
30
30
 
31
- export { ALL_TOOLS } from './tools';
31
+ export { ALL_ENTRIES, ALL_TOOLS } from './tools';
32
32
 
@@ -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,23 @@
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
+ ALL_TOOLS.forEach((tool) => {
7
+ describe(`Tool: ${tool.entry.id}`, () => {
8
+ it('slug should not end with 2-letter language codes like -ja, -ru, -ko', async () => {
9
+ const locales = Object.keys(tool.entry.i18n);
10
+
11
+ for (const locale of locales) {
12
+ const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
13
+ const content = (await loader?.()) as ToolLocaleContent;
14
+
15
+ expect(
16
+ content.slug,
17
+ `Tool "${tool.entry.id}" locale "${locale}" slug ("${content.slug}") cannot end with a 2-letter language code (e.g., -ja, -ru, -ko).`,
18
+ ).not.toMatch(/-(?!ye$)[a-z]{2}$/);
19
+ }
20
+ });
21
+ });
22
+ });
23
+ });
@@ -1,7 +1,4 @@
1
1
  import type { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import BurnTestComponent from './component.astro';
3
- import BurnTestSEO from './seo.astro';
4
- import BurnTestBibliography from './bibliography.astro';
5
2
 
6
3
  import type { BurnTestUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const burnTest: TextilesToolEntry<BurnTestUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { BurnTestComponent, BurnTestSEO, BurnTestBibliography };
36
32
 
37
33
  export const BURN_TEST_TOOL: ToolDefinition = {
38
34
  entry: burnTest,
39
- Component: BurnTestComponent,
40
- SEOComponent: BurnTestSEO,
41
- BibliographyComponent: BurnTestBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import ClothingSizeConverterComponent from './component.astro';
3
- import ClothingSizeConverterSEO from './seo.astro';
4
- import ClothingSizeConverterBibliography from './bibliography.astro';
5
2
 
6
3
  import type { ClothingSizeConverterUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const clothingSizeConverter: TextilesToolEntry<ClothingSizeConverterUI> =
32
29
  },
33
30
  };
34
31
 
35
- export { ClothingSizeConverterComponent, ClothingSizeConverterSEO, ClothingSizeConverterBibliography };
36
32
 
37
33
  export const CLOTHING_SIZE_CONVERTER_TOOL: ToolDefinition = {
38
34
  entry: clothingSizeConverter,
39
- Component: ClothingSizeConverterComponent,
40
- SEOComponent: ClothingSizeConverterSEO,
41
- BibliographyComponent: ClothingSizeConverterBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import FabricProjectCalculatorComponent from './component.astro';
3
- import FabricProjectCalculatorSEO from './seo.astro';
4
- import FabricProjectCalculatorBibliography from './bibliography.astro';
5
2
 
6
3
  import type { FabricProjectCalculatorUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const fabricProjectCalculator: TextilesToolEntry<FabricProjectCalculatorU
32
29
  },
33
30
  };
34
31
 
35
- export { FabricProjectCalculatorComponent, FabricProjectCalculatorSEO, FabricProjectCalculatorBibliography };
36
32
 
37
33
  export const FABRIC_PROJECT_CALCULATOR_TOOL: ToolDefinition = {
38
34
  entry: fabricProjectCalculator,
39
- Component: FabricProjectCalculatorComponent,
40
- SEOComponent: FabricProjectCalculatorSEO,
41
- BibliographyComponent: FabricProjectCalculatorBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import FabricTruthComponent from './component.astro';
3
- import FabricTruthSEO from './seo.astro';
4
- import FabricTruthBibliography from './bibliography.astro';
5
2
 
6
3
  import type { FabricTruthUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const fabricTruth: TextilesToolEntry<FabricTruthUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { FabricTruthComponent, FabricTruthSEO, FabricTruthBibliography };
36
32
 
37
33
  export const FABRIC_TRUTH_TOOL: ToolDefinition = {
38
34
  entry: fabricTruth,
39
- Component: FabricTruthComponent,
40
- SEOComponent: FabricTruthSEO,
41
- BibliographyComponent: FabricTruthBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import FiberPrepComponent from './component.astro';
3
- import FiberPrepSEO from './seo.astro';
4
- import FiberPrepBibliography from './bibliography.astro';
5
2
 
6
3
  import type { FiberPrepUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const fiberPrep: TextilesToolEntry<FiberPrepUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { FiberPrepComponent, FiberPrepSEO, FiberPrepBibliography };
36
32
 
37
33
  export const FIBER_PREP_TOOL: ToolDefinition = {
38
34
  entry: fiberPrep,
39
- Component: FiberPrepComponent,
40
- SEOComponent: FiberPrepSEO,
41
- BibliographyComponent: FiberPrepBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import KnittingGaugeComponent from './component.astro';
3
- import KnittingGaugeSEO from './seo.astro';
4
- import KnittingGaugeBibliography from './bibliography.astro';
5
2
 
6
3
  import type { KnittingGaugeUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const knittingGauge: TextilesToolEntry<KnittingGaugeUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { KnittingGaugeComponent, KnittingGaugeSEO, KnittingGaugeBibliography };
36
32
 
37
33
  export const KNITTING_GAUGE_TOOL: ToolDefinition = {
38
34
  entry: knittingGauge,
39
- Component: KnittingGaugeComponent,
40
- SEOComponent: KnittingGaugeSEO,
41
- BibliographyComponent: KnittingGaugeBibliography,
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 { TextilesToolEntry, ToolDefinition } from '../../types';
2
- import LaundryGuideComponent from './component.astro';
3
- import LaundryGuideSEO from './seo.astro';
4
- import LaundryGuideBibliography from './bibliography.astro';
5
2
  export const laundryGuide: TextilesToolEntry = {
6
3
  id: 'laundry-guide',
7
4
  icons: {
@@ -27,11 +24,10 @@ export const laundryGuide: TextilesToolEntry = {
27
24
  },
28
25
  };
29
26
 
30
- export { LaundryGuideComponent, LaundryGuideSEO, LaundryGuideBibliography };
31
27
 
32
28
  export const LAUNDRY_GUIDE_TOOL: ToolDefinition = {
33
29
  entry: laundryGuide,
34
- Component: LaundryGuideComponent,
35
- SEOComponent: LaundryGuideSEO,
36
- BibliographyComponent: LaundryGuideBibliography,
30
+ Component: () => import('./component.astro'),
31
+ SEOComponent: () => import('./seo.astro'),
32
+ BibliographyComponent: () => import('./bibliography.astro'),
37
33
  };
@@ -1,7 +1,4 @@
1
1
  import type { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import NeedleConverterComponent from './component.astro';
3
- import NeedleConverterSEO from './seo.astro';
4
- import NeedleConverterBibliography from './bibliography.astro';
5
2
 
6
3
  import type { NeedleConverterUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const needleConverter: TextilesToolEntry<NeedleConverterUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { NeedleConverterComponent, NeedleConverterSEO, NeedleConverterBibliography };
36
32
 
37
33
  export const NEEDLE_CONVERTER_TOOL: ToolDefinition = {
38
34
  entry: needleConverter,
39
- Component: NeedleConverterComponent,
40
- SEOComponent: NeedleConverterSEO,
41
- BibliographyComponent: NeedleConverterBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import SewingPatternScalerComponent from './component.astro';
3
- import SewingPatternScalerSEO from './seo.astro';
4
- import SewingPatternScalerBibliography from './bibliography.astro';
5
2
 
6
3
  import type { SewingPatternScalerUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const sewingPatternScaler: TextilesToolEntry<SewingPatternScalerUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { SewingPatternScalerComponent, SewingPatternScalerSEO, SewingPatternScalerBibliography };
36
32
 
37
33
  export const SEWING_PATTERN_SCALER_TOOL: ToolDefinition = {
38
34
  entry: sewingPatternScaler,
39
- Component: SewingPatternScalerComponent,
40
- SEOComponent: SewingPatternScalerSEO,
41
- BibliographyComponent: SewingPatternScalerBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import ShoeSizeConverterComponent from './component.astro';
3
- import ShoeSizeConverterSEO from './seo.astro';
4
- import ShoeSizeConverterBibliography from './bibliography.astro';
5
2
 
6
3
  import type { ShoeSizeConverterUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const shoeSizeConverter: TextilesToolEntry<ShoeSizeConverterUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { ShoeSizeConverterComponent, ShoeSizeConverterSEO, ShoeSizeConverterBibliography };
36
32
 
37
33
  export const SHOE_SIZE_CONVERTER_TOOL: ToolDefinition = {
38
34
  entry: shoeSizeConverter,
39
- Component: ShoeSizeConverterComponent,
40
- SEOComponent: ShoeSizeConverterSEO,
41
- BibliographyComponent: ShoeSizeConverterBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import StainChemistryComponent from './component.astro';
3
- import StainChemistrySEO from './seo.astro';
4
- import StainChemistryBibliography from './bibliography.astro';
5
2
 
6
3
  import type { StainChemistryUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const stainChemistry: TextilesToolEntry<StainChemistryUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { StainChemistryComponent, StainChemistrySEO, StainChemistryBibliography };
36
32
 
37
33
  export const STAIN_CHEMISTRY_TOOL: ToolDefinition = {
38
34
  entry: stainChemistry,
39
- Component: StainChemistryComponent,
40
- SEOComponent: StainChemistrySEO,
41
- BibliographyComponent: StainChemistryBibliography,
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 { TextilesToolEntry, ToolLocaleContent, ToolDefinition } from '../../types';
2
- import YarnCalculatorComponent from './component.astro';
3
- import YarnCalculatorSEO from './seo.astro';
4
- import YarnCalculatorBibliography from './bibliography.astro';
5
2
 
6
3
  import type { YarnCalculatorUI } from './ui';
7
4
 
@@ -32,11 +29,10 @@ export const yarnCalculator: TextilesToolEntry<YarnCalculatorUI> = {
32
29
  },
33
30
  };
34
31
 
35
- export { YarnCalculatorComponent, YarnCalculatorSEO, YarnCalculatorBibliography };
36
32
 
37
33
  export const YARN_CALCULATOR_TOOL: ToolDefinition = {
38
34
  entry: yarnCalculator,
39
- Component: YarnCalculatorComponent,
40
- SEOComponent: YarnCalculatorSEO,
41
- BibliographyComponent: YarnCalculatorBibliography,
35
+ Component: () => import('./component.astro'),
36
+ SEOComponent: () => import('./seo.astro'),
37
+ BibliographyComponent: () => import('./bibliography.astro'),
42
38
  };
package/src/tools.ts CHANGED
@@ -14,3 +14,5 @@ import { YARN_CALCULATOR_TOOL } from './tool/yarnCalculator/index';
14
14
 
15
15
  export const ALL_TOOLS: ToolDefinition[] = [FABRIC_TRUTH_TOOL, LAUNDRY_GUIDE_TOOL, STAIN_CHEMISTRY_TOOL, BURN_TEST_TOOL, FIBER_PREP_TOOL, SHOE_SIZE_CONVERTER_TOOL, CLOTHING_SIZE_CONVERTER_TOOL, KNITTING_GAUGE_TOOL, FABRIC_PROJECT_CALCULATOR_TOOL, SEWING_PATTERN_SCALER_TOOL, NEEDLE_CONVERTER_TOOL, YARN_CALCULATOR_TOOL];
16
16
 
17
+
18
+ export const ALL_ENTRIES = ALL_TOOLS.map(t => t.entry);