@jjlmoya/utils-tools 1.5.0 → 1.6.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-tools",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,7 +1,7 @@
1
1
  import type { CategoryLocaleContent } from '../../types';
2
2
 
3
3
  export const content: CategoryLocaleContent = {
4
- slug: 'tools',
4
+ slug: 'hulpmiddelen',
5
5
  title: 'Praktische Online Multi Tools',
6
6
  description: 'Los alledaagse problemen op met gratis online tools. Route-optimizers, wachtwoordgenerators, RSVP-snellezen en snelle rekenhulpmiddelen.',
7
7
  seo: [
package/src/index.ts CHANGED
@@ -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 { routes, ROUTES_TOOL } from './tool/routes/index';
21
21
  export { default as RoutesComponent } from './tool/routes/component.astro';
@@ -0,0 +1,58 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { toolsCategory } from '../category/index';
3
+ import type { CategoryLocaleContent } from '../types';
4
+
5
+ const EXPECTED_LOCALES = [
6
+ 'de', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'zh'
7
+ ];
8
+
9
+ const sharingLocales = ['ja', 'ko', 'zh'];
10
+
11
+ describe('Category Validation', () => {
12
+ it('should have all 15 required locales', () => {
13
+ const registeredLocales = Object.keys(toolsCategory.i18n);
14
+ EXPECTED_LOCALES.forEach((locale) => {
15
+ expect(
16
+ registeredLocales,
17
+ `Category is missing locale "${locale}"`,
18
+ ).toContain(locale);
19
+ });
20
+ });
21
+
22
+ describe('Category Slug Validation', () => {
23
+ async function getEnSlug(locales: string[]): Promise<string> {
24
+ if (!locales.includes('en')) return '';
25
+ const enLoader = toolsCategory.i18n['en' as keyof typeof toolsCategory.i18n];
26
+ const enContent = (await enLoader?.()) as CategoryLocaleContent;
27
+ return enContent.slug;
28
+ }
29
+
30
+ function validateNonEnSlug(locale: string, slug: string, enSlug: string, slugs: Map<string, string>) {
31
+ if (sharingLocales.includes(locale)) {
32
+ expect(slug, `Category locale "${locale}" must use the same slug as "en" ("${enSlug}").`).toBe(enSlug);
33
+ } else {
34
+ expect(slug, `Category locale "${locale}" has the same slug as "en" ("${enSlug}"). Cada slug tiene que estar en su propio idioma`).not.toBe(enSlug);
35
+ if (slugs.has(slug)) {
36
+ expect(false, `Category locales "${locale}" and "${slugs.get(slug)}" share the same slug ("${slug}"). Cada slug tiene que estar en su propia idioma`).toBe(true);
37
+ }
38
+ slugs.set(slug, locale);
39
+ }
40
+ }
41
+
42
+ it('every locale should have a unique, translated slug and follow format rules', async () => {
43
+ const slugs = new Map<string, string>();
44
+ const locales = Object.keys(toolsCategory.i18n);
45
+ const enSlug = await getEnSlug(locales);
46
+
47
+ for (const locale of locales) {
48
+ const loader = toolsCategory.i18n[locale as keyof typeof toolsCategory.i18n];
49
+ const content = (await loader?.()) as CategoryLocaleContent;
50
+
51
+ expect(content.slug, `Category locale "${locale}" has an invalid slug ("${content.slug}"). Slugs must be transliterated (only a-z, 0-9, and -).`).toMatch(/^[a-z0-9-]+$/);
52
+ expect(content.slug, `Category locale "${locale}" slug ("${content.slug}") cannot end with a 2-letter language code (e.g., -ja, -ru, -ko).`).not.toMatch(/-[a-z]{2}$/);
53
+
54
+ if (locale !== 'en') validateNonEnSlug(locale, content.slug, enSlug, slugs);
55
+ }
56
+ });
57
+ });
58
+ });
package/src/tools.ts CHANGED
@@ -13,3 +13,5 @@ import { DRIVE_DIRECT_LINK_TOOL } from './tool/drive-direct-link/index';
13
13
  import { SEO_CONTENT_OPTIMIZER_TOOL } from './tool/seo-content-optimizer/index';
14
14
 
15
15
  export const ALL_TOOLS: ToolDefinition[] = [ROUTES_TOOL, RULE_OF_THREE_TOOL, PASSWORD_GENERATOR_TOOL, MORSE_BEACON_TOOL, SPEED_READER_TOOL, WHATSAPP_LINK_TOOL, TEXT_PIXEL_CALCULATOR_TOOL, DATE_DIFF_CALCULATOR_TOOL, EMAIL_LIST_CLEANER_TOOL, ENV_BADGE_SPAIN_TOOL, DRIVE_DIRECT_LINK_TOOL, SEO_CONTENT_OPTIMIZER_TOOL];
16
+
17
+ export const ALL_ENTRIES = ALL_TOOLS.map(t => t.entry);