@jjlmoya/utils-chrono 1.2.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 +65 -0
- package/scripts/postinstall.mjs +27 -0
- package/src/category/ChronoCategorySEO.astro +8 -0
- package/src/category/i18n/de.ts +23 -0
- package/src/category/i18n/en.ts +23 -0
- package/src/category/i18n/es.ts +23 -0
- package/src/category/i18n/fr.ts +23 -0
- package/src/category/i18n/id.ts +23 -0
- package/src/category/i18n/it.ts +23 -0
- package/src/category/i18n/ja.ts +23 -0
- package/src/category/i18n/ko.ts +23 -0
- package/src/category/i18n/nl.ts +23 -0
- package/src/category/i18n/pl.ts +23 -0
- package/src/category/i18n/pt.ts +23 -0
- package/src/category/i18n/ru.ts +23 -0
- package/src/category/i18n/sv.ts +23 -0
- package/src/category/i18n/tr.ts +23 -0
- package/src/category/i18n/zh.ts +23 -0
- package/src/category/index.ts +42 -0
- package/src/components/PreviewNavSidebar.astro +116 -0
- package/src/components/PreviewToolbar.astro +143 -0
- package/src/data.ts +11 -0
- package/src/entries.ts +32 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +28 -0
- package/src/layouts/PreviewLayout.astro +117 -0
- package/src/pages/[locale]/[slug].astro +161 -0
- package/src/pages/[locale].astro +251 -0
- package/src/pages/index.astro +4 -0
- package/src/tests/faq_count.test.ts +19 -0
- package/src/tests/i18n_coverage.test.ts +36 -0
- package/src/tests/locale_completeness.test.ts +29 -0
- package/src/tests/mocks/astro_mock.js +2 -0
- package/src/tests/no_h1_in_components.test.ts +48 -0
- package/src/tests/schemas_fulfillment.test.ts +23 -0
- package/src/tests/seo_length.test.ts +22 -0
- package/src/tests/shared-test-helpers.ts +56 -0
- package/src/tests/slug_language_code_format.test.ts +23 -0
- package/src/tests/slug_uniqueness.test.ts +81 -0
- package/src/tests/title_quality.test.ts +55 -0
- package/src/tests/tool_exports.test.ts +34 -0
- package/src/tests/tool_validation.test.ts +18 -0
- package/src/tool/beat-rate-converter/beat-rate-converter.css +301 -0
- package/src/tool/beat-rate-converter/bibliography.astro +16 -0
- package/src/tool/beat-rate-converter/bibliography.ts +12 -0
- package/src/tool/beat-rate-converter/client.ts +46 -0
- package/src/tool/beat-rate-converter/component.astro +15 -0
- package/src/tool/beat-rate-converter/components/ConverterPanel.astro +87 -0
- package/src/tool/beat-rate-converter/entry.ts +42 -0
- package/src/tool/beat-rate-converter/i18n/de.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/en.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/es.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/fr.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/id.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/it.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/ja.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/ko.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/nl.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/pl.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/pt.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/ru.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/sv.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/tr.ts +138 -0
- package/src/tool/beat-rate-converter/i18n/zh.ts +138 -0
- package/src/tool/beat-rate-converter/index.ts +11 -0
- package/src/tool/beat-rate-converter/seo.astro +16 -0
- package/src/tool/crown-reference-guide/bibliography.astro +16 -0
- package/src/tool/crown-reference-guide/bibliography.ts +20 -0
- package/src/tool/crown-reference-guide/client.ts +193 -0
- package/src/tool/crown-reference-guide/component.astro +69 -0
- package/src/tool/crown-reference-guide/components/CrownView.astro +40 -0
- package/src/tool/crown-reference-guide/components/MovementSelector.astro +26 -0
- package/src/tool/crown-reference-guide/components/PositionPanel.astro +59 -0
- package/src/tool/crown-reference-guide/crown-reference-guide.css +383 -0
- package/src/tool/crown-reference-guide/entry.ts +60 -0
- package/src/tool/crown-reference-guide/i18n/de.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/en.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/es.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/fr.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/id.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/it.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/ja.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/ko.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/nl.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/pl.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/pt.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/ru.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/sv.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/tr.ts +207 -0
- package/src/tool/crown-reference-guide/i18n/zh.ts +207 -0
- package/src/tool/crown-reference-guide/index.ts +11 -0
- package/src/tool/crown-reference-guide/seo.astro +16 -0
- package/src/tool/crown-reference-guide/utils.ts +0 -0
- package/src/tool/demagnetizing-timer/bibliography.astro +16 -0
- package/src/tool/demagnetizing-timer/bibliography.ts +12 -0
- package/src/tool/demagnetizing-timer/client.ts +221 -0
- package/src/tool/demagnetizing-timer/component.astro +15 -0
- package/src/tool/demagnetizing-timer/components/TimerPanel.astro +92 -0
- package/src/tool/demagnetizing-timer/demagnetizing-timer.css +389 -0
- package/src/tool/demagnetizing-timer/entry.ts +50 -0
- package/src/tool/demagnetizing-timer/helpers/field.ts +134 -0
- package/src/tool/demagnetizing-timer/i18n/de.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/en.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/es.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/fr.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/id.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/it.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/ja.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/ko.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/nl.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/pl.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/pt.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/ru.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/sv.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/tr.ts +143 -0
- package/src/tool/demagnetizing-timer/i18n/zh.ts +143 -0
- package/src/tool/demagnetizing-timer/index.ts +11 -0
- package/src/tool/demagnetizing-timer/seo.astro +16 -0
- package/src/tool/demagnetizing-timer/utils.ts +0 -0
- package/src/tool/power-reserve-estimator/bibliography.astro +16 -0
- package/src/tool/power-reserve-estimator/bibliography.ts +16 -0
- package/src/tool/power-reserve-estimator/client.ts +139 -0
- package/src/tool/power-reserve-estimator/component.astro +15 -0
- package/src/tool/power-reserve-estimator/components/EstimatorPanel.astro +150 -0
- package/src/tool/power-reserve-estimator/entry.ts +51 -0
- package/src/tool/power-reserve-estimator/i18n/de.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/en.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/es.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/fr.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/id.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/it.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/ja.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/ko.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/nl.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/pl.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/pt.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/ru.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/sv.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/tr.ts +158 -0
- package/src/tool/power-reserve-estimator/i18n/zh.ts +158 -0
- package/src/tool/power-reserve-estimator/index.ts +11 -0
- package/src/tool/power-reserve-estimator/power-reserve-estimator.css +402 -0
- package/src/tool/power-reserve-estimator/seo.astro +16 -0
- package/src/tool/strap-taper-calculator/bibliography.astro +16 -0
- package/src/tool/strap-taper-calculator/bibliography.ts +12 -0
- package/src/tool/strap-taper-calculator/client.ts +129 -0
- package/src/tool/strap-taper-calculator/component.astro +15 -0
- package/src/tool/strap-taper-calculator/components/CalculatorPanel.astro +114 -0
- package/src/tool/strap-taper-calculator/entry.ts +56 -0
- package/src/tool/strap-taper-calculator/i18n/de.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/en.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/es.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/fr.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/id.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/it.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/ja.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/ko.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/nl.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/pl.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/pt.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/ru.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/sv.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/tr.ts +152 -0
- package/src/tool/strap-taper-calculator/i18n/zh.ts +152 -0
- package/src/tool/strap-taper-calculator/index.ts +11 -0
- package/src/tool/strap-taper-calculator/seo.astro +16 -0
- package/src/tool/strap-taper-calculator/strap-taper-calculator.css +320 -0
- package/src/tool/watch-accuracy-tracker/bibliography.astro +16 -0
- package/src/tool/watch-accuracy-tracker/bibliography.ts +12 -0
- package/src/tool/watch-accuracy-tracker/chart.ts +126 -0
- package/src/tool/watch-accuracy-tracker/client.ts +287 -0
- package/src/tool/watch-accuracy-tracker/component.astro +35 -0
- package/src/tool/watch-accuracy-tracker/components/AccuracyTracker.astro +96 -0
- package/src/tool/watch-accuracy-tracker/components/DriftPredictor.astro +126 -0
- package/src/tool/watch-accuracy-tracker/components/LogHistory.astro +66 -0
- package/src/tool/watch-accuracy-tracker/entry.ts +94 -0
- package/src/tool/watch-accuracy-tracker/i18n/de.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/en.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/es.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/fr.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/id.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/it.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/ja.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/ko.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/nl.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/pl.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/pt.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/ru.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/sv.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/tr.ts +167 -0
- package/src/tool/watch-accuracy-tracker/i18n/zh.ts +167 -0
- package/src/tool/watch-accuracy-tracker/index.ts +9 -0
- package/src/tool/watch-accuracy-tracker/logger.ts +105 -0
- package/src/tool/watch-accuracy-tracker/seo.astro +16 -0
- package/src/tool/watch-accuracy-tracker/utils.ts +99 -0
- package/src/tool/watch-accuracy-tracker/watch-accuracy-tracker.css +564 -0
- package/src/tool/watch-savings-planner/bibliography.astro +16 -0
- package/src/tool/watch-savings-planner/bibliography.ts +8 -0
- package/src/tool/watch-savings-planner/client.ts +271 -0
- package/src/tool/watch-savings-planner/component.astro +33 -0
- package/src/tool/watch-savings-planner/components/AddGoalForm.astro +49 -0
- package/src/tool/watch-savings-planner/components/GoalCard.astro +58 -0
- package/src/tool/watch-savings-planner/entry.ts +62 -0
- package/src/tool/watch-savings-planner/i18n/de.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/en.ts +155 -0
- package/src/tool/watch-savings-planner/i18n/es.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/fr.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/id.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/it.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/ja.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/ko.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/nl.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/pl.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/pt.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/ru.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/sv.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/tr.ts +153 -0
- package/src/tool/watch-savings-planner/i18n/zh.ts +153 -0
- package/src/tool/watch-savings-planner/index.ts +11 -0
- package/src/tool/watch-savings-planner/seo.astro +16 -0
- package/src/tool/watch-savings-planner/utils.ts +0 -0
- package/src/tool/watch-savings-planner/watch-savings-planner.css +460 -0
- package/src/tool/water-resistance-converter/bibliography.astro +16 -0
- package/src/tool/water-resistance-converter/bibliography.ts +16 -0
- package/src/tool/water-resistance-converter/client.ts +56 -0
- package/src/tool/water-resistance-converter/component.astro +15 -0
- package/src/tool/water-resistance-converter/components/ConverterPanel.astro +113 -0
- package/src/tool/water-resistance-converter/entry.ts +52 -0
- package/src/tool/water-resistance-converter/i18n/de.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/en.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/es.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/fr.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/id.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/it.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/ja.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/ko.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/nl.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/pl.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/pt.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/ru.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/sv.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/tr.ts +148 -0
- package/src/tool/water-resistance-converter/i18n/zh.ts +148 -0
- package/src/tool/water-resistance-converter/index.ts +11 -0
- package/src/tool/water-resistance-converter/seo.astro +16 -0
- package/src/tool/water-resistance-converter/water-resistance-converter.css +254 -0
- package/src/tool/wrist-presence-calculator/bibliography.astro +16 -0
- package/src/tool/wrist-presence-calculator/bibliography.ts +12 -0
- package/src/tool/wrist-presence-calculator/client.ts +180 -0
- package/src/tool/wrist-presence-calculator/component.astro +23 -0
- package/src/tool/wrist-presence-calculator/components/CalculatorInputs.astro +97 -0
- package/src/tool/wrist-presence-calculator/components/FitResult.astro +68 -0
- package/src/tool/wrist-presence-calculator/components/Visualizer.astro +16 -0
- package/src/tool/wrist-presence-calculator/entry.ts +59 -0
- package/src/tool/wrist-presence-calculator/helpers/canvas.ts +189 -0
- package/src/tool/wrist-presence-calculator/helpers/results.ts +78 -0
- package/src/tool/wrist-presence-calculator/i18n/de.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/en.ts +155 -0
- package/src/tool/wrist-presence-calculator/i18n/es.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/fr.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/id.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/it.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/ja.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/ko.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/nl.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/pl.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/pt.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/ru.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/sv.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/tr.ts +139 -0
- package/src/tool/wrist-presence-calculator/i18n/zh.ts +155 -0
- package/src/tool/wrist-presence-calculator/index.ts +11 -0
- package/src/tool/wrist-presence-calculator/seo.astro +16 -0
- package/src/tool/wrist-presence-calculator/utils.ts +30 -0
- package/src/tool/wrist-presence-calculator/wrist-presence-calculator.css +372 -0
- package/src/tools.ts +26 -0
- package/src/types.ts +70 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
import PreviewLayout from '../layouts/PreviewLayout.astro';
|
|
3
|
+
import PreviewNavSidebar from '../components/PreviewNavSidebar.astro';
|
|
4
|
+
import { chronoCategory, ALL_TOOLS } from '../index';
|
|
5
|
+
import { Icon } from 'astro-icon/components';
|
|
6
|
+
import type { KnownLocale, ToolLocaleContent } from '../types';
|
|
7
|
+
|
|
8
|
+
export async function getStaticPaths() {
|
|
9
|
+
const locales = ['en', 'es', 'fr'] as KnownLocale[];
|
|
10
|
+
return locales.map(locale => ({ params: { locale } }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { locale: currentLocale } = Astro.params as { locale: KnownLocale };
|
|
14
|
+
|
|
15
|
+
const categoryContent = await chronoCategory.i18n[currentLocale]!();
|
|
16
|
+
|
|
17
|
+
const tools = ALL_TOOLS || [];
|
|
18
|
+
|
|
19
|
+
const toolsWithContent = tools.length > 0
|
|
20
|
+
? await Promise.all(
|
|
21
|
+
tools.map(async ({ entry, Component }) => {
|
|
22
|
+
const languages = Object.keys(entry.i18n);
|
|
23
|
+
const localeEntries = await Promise.all(
|
|
24
|
+
languages.map(async (l) => {
|
|
25
|
+
const content = await entry.i18n[l as KnownLocale]!();
|
|
26
|
+
return [l, content];
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const localeContents = Object.fromEntries(localeEntries) as Record<string, ToolLocaleContent<Record<string, string>>>;
|
|
31
|
+
|
|
32
|
+
const currentLocaleContent = localeContents[currentLocale] || localeContents['en'] || localeContents['es'];
|
|
33
|
+
const availableLocales: Record<string, string> = {};
|
|
34
|
+
|
|
35
|
+
for (const l of languages) {
|
|
36
|
+
const lCont = localeContents[l];
|
|
37
|
+
if (lCont) {
|
|
38
|
+
availableLocales[l] = `/${l}/${lCont.slug}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { entry, Component, locale: currentLocaleContent, availableLocales };
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
: [];
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
<PreviewLayout
|
|
49
|
+
title={categoryContent.title}
|
|
50
|
+
currentLocale={currentLocale}
|
|
51
|
+
hasSidebar={true}
|
|
52
|
+
>
|
|
53
|
+
<PreviewNavSidebar
|
|
54
|
+
slot="sidebar"
|
|
55
|
+
categoryTitle={categoryContent.title}
|
|
56
|
+
tools={toolsWithContent.map(({ entry, locale, availableLocales }) => {
|
|
57
|
+
const href = availableLocales[currentLocale] || (locale ? `/${currentLocale}/${locale.slug}` : '#');
|
|
58
|
+
return {
|
|
59
|
+
id: entry.id,
|
|
60
|
+
title: locale?.title || entry.id,
|
|
61
|
+
href: href,
|
|
62
|
+
};
|
|
63
|
+
})}
|
|
64
|
+
/>
|
|
65
|
+
<div class="dashboard">
|
|
66
|
+
<header class="preview-header">
|
|
67
|
+
<span class="badge">preview · @jjlmoya/utils-chrono</span>
|
|
68
|
+
<h1>{categoryContent.title}</h1>
|
|
69
|
+
<p>{categoryContent.description}</p>
|
|
70
|
+
</header>
|
|
71
|
+
|
|
72
|
+
<div class="tool-list">
|
|
73
|
+
{toolsWithContent?.map(({ entry, locale, availableLocales }) => (
|
|
74
|
+
<article class="tool-card">
|
|
75
|
+
<a href={availableLocales?.[currentLocale] || (locale ? `/${currentLocale}/${locale.slug}` : '#')} class="tool-card-link">
|
|
76
|
+
<div class="tool-icons">
|
|
77
|
+
<div class="icon-wrapper bg">
|
|
78
|
+
<Icon name={entry.icons.bg} />
|
|
79
|
+
</div>
|
|
80
|
+
<div class="icon-wrapper fg">
|
|
81
|
+
<Icon name={entry.icons.fg} />
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="tool-card-content">
|
|
85
|
+
<h2 class="tool-title">{locale?.title}</h2>
|
|
86
|
+
<p class="tool-description">{locale?.description}</p>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="tool-card-meta">
|
|
89
|
+
<span class="tool-id">{entry.id}</span>
|
|
90
|
+
</div>
|
|
91
|
+
</a>
|
|
92
|
+
|
|
93
|
+
{availableLocales && Object.keys(availableLocales).length > 1 && (
|
|
94
|
+
<div class="tool-locales">
|
|
95
|
+
{Object.entries(availableLocales).map(([l, url]) => (
|
|
96
|
+
<a href={url} class="locale-badge" title={`Ver en ${l.toUpperCase()}`} class:list={{ active: l === currentLocale }}>
|
|
97
|
+
{l.toUpperCase()}
|
|
98
|
+
</a>
|
|
99
|
+
))}
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
102
|
+
</article>
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</PreviewLayout>
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
.dashboard {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
gap: 5rem;
|
|
113
|
+
}
|
|
114
|
+
.preview-header {
|
|
115
|
+
text-align: center;
|
|
116
|
+
padding-bottom: 3rem;
|
|
117
|
+
border-bottom: 1px solid var(--border-color);
|
|
118
|
+
}
|
|
119
|
+
.badge {
|
|
120
|
+
display: inline-block;
|
|
121
|
+
padding: 0.25rem 0.75rem;
|
|
122
|
+
background: var(--accent);
|
|
123
|
+
border-radius: 99px;
|
|
124
|
+
font-size: 0.7rem;
|
|
125
|
+
font-weight: 800;
|
|
126
|
+
margin-bottom: 1.5rem;
|
|
127
|
+
color: var(--text-base);
|
|
128
|
+
letter-spacing: 0.05em;
|
|
129
|
+
}
|
|
130
|
+
h1 {
|
|
131
|
+
font-size: clamp(2rem, 6vw, 3.5rem);
|
|
132
|
+
font-weight: 900;
|
|
133
|
+
margin: 0 0 1rem;
|
|
134
|
+
background: linear-gradient(to bottom, var(--text-base), var(--text-muted));
|
|
135
|
+
-webkit-background-clip: text;
|
|
136
|
+
-webkit-text-fill-color: transparent;
|
|
137
|
+
background-clip: text;
|
|
138
|
+
}
|
|
139
|
+
.preview-header p {
|
|
140
|
+
color: var(--text-muted);
|
|
141
|
+
font-size: 1.1rem;
|
|
142
|
+
margin: 0;
|
|
143
|
+
}
|
|
144
|
+
.tool-list {
|
|
145
|
+
display: grid;
|
|
146
|
+
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
|
147
|
+
gap: 2rem;
|
|
148
|
+
}
|
|
149
|
+
.tool-card {
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-direction: column;
|
|
152
|
+
gap: 1rem;
|
|
153
|
+
}
|
|
154
|
+
.tool-card-link {
|
|
155
|
+
flex: 1;
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
padding: 1.5rem;
|
|
159
|
+
background: var(--bg-surface);
|
|
160
|
+
border: 1px solid var(--border-color);
|
|
161
|
+
border-radius: 0.75rem;
|
|
162
|
+
text-decoration: none;
|
|
163
|
+
transition: all 0.2s ease;
|
|
164
|
+
}
|
|
165
|
+
.tool-card-link:hover {
|
|
166
|
+
border-color: var(--accent);
|
|
167
|
+
background: rgba(244, 63, 94, 0.05);
|
|
168
|
+
transform: translateY(-2px);
|
|
169
|
+
}
|
|
170
|
+
.tool-icons {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
gap: 1rem;
|
|
174
|
+
margin-bottom: 1.25rem;
|
|
175
|
+
}
|
|
176
|
+
.icon-wrapper {
|
|
177
|
+
display: flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
width: 3rem;
|
|
181
|
+
height: 3rem;
|
|
182
|
+
border-radius: 0.5rem;
|
|
183
|
+
font-size: 1.5rem;
|
|
184
|
+
}
|
|
185
|
+
.icon-wrapper.bg {
|
|
186
|
+
background: var(--accent);
|
|
187
|
+
color: var(--text-base);
|
|
188
|
+
}
|
|
189
|
+
.icon-wrapper.fg {
|
|
190
|
+
background: var(--bg-page);
|
|
191
|
+
border: 1px solid var(--border-color);
|
|
192
|
+
color: var(--accent);
|
|
193
|
+
}
|
|
194
|
+
.tool-card-content {
|
|
195
|
+
flex: 1;
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-direction: column;
|
|
198
|
+
}
|
|
199
|
+
.tool-title {
|
|
200
|
+
font-size: 1.25rem;
|
|
201
|
+
font-weight: 700;
|
|
202
|
+
margin: 0 0 0.5rem;
|
|
203
|
+
color: var(--text-base);
|
|
204
|
+
}
|
|
205
|
+
.tool-description {
|
|
206
|
+
font-size: 0.9375rem;
|
|
207
|
+
color: var(--text-muted);
|
|
208
|
+
line-height: 1.5;
|
|
209
|
+
margin: 0;
|
|
210
|
+
}
|
|
211
|
+
.tool-card-meta {
|
|
212
|
+
padding-top: 1rem;
|
|
213
|
+
border-top: 1px solid var(--border-color);
|
|
214
|
+
margin-top: 1.5rem;
|
|
215
|
+
}
|
|
216
|
+
.tool-id {
|
|
217
|
+
display: inline-block;
|
|
218
|
+
font-size: 0.7rem;
|
|
219
|
+
background: var(--bg-page);
|
|
220
|
+
border: 1px solid var(--border-color);
|
|
221
|
+
padding: 0.35rem 0.75rem;
|
|
222
|
+
border-radius: 0.4rem;
|
|
223
|
+
color: var(--accent);
|
|
224
|
+
font-weight: 600;
|
|
225
|
+
}
|
|
226
|
+
.tool-locales {
|
|
227
|
+
display: flex;
|
|
228
|
+
gap: 0.5rem;
|
|
229
|
+
flex-wrap: wrap;
|
|
230
|
+
}
|
|
231
|
+
.locale-badge {
|
|
232
|
+
display: inline-block;
|
|
233
|
+
padding: 0.4rem 0.85rem;
|
|
234
|
+
background: var(--bg-page);
|
|
235
|
+
border: 1px solid var(--border-color);
|
|
236
|
+
border-radius: 0.4rem;
|
|
237
|
+
color: var(--text-muted);
|
|
238
|
+
text-decoration: none;
|
|
239
|
+
font-size: 0.75rem;
|
|
240
|
+
font-weight: 600;
|
|
241
|
+
text-transform: uppercase;
|
|
242
|
+
letter-spacing: 0.05em;
|
|
243
|
+
transition: all 0.15s ease;
|
|
244
|
+
}
|
|
245
|
+
.locale-badge:hover,
|
|
246
|
+
.locale-badge.active {
|
|
247
|
+
color: var(--accent);
|
|
248
|
+
border-color: var(--accent);
|
|
249
|
+
background: rgba(244, 63, 94, 0.1);
|
|
250
|
+
}
|
|
251
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import type * as DATA from '../data';
|
|
3
|
+
|
|
4
|
+
const TOOLS: typeof DATA.audiovisualCategory[] = [];
|
|
5
|
+
|
|
6
|
+
describe('FAQ Content Validation', () => {
|
|
7
|
+
TOOLS.forEach((entry) => {
|
|
8
|
+
describe(`Tool: ${entry.icon}`, () => {
|
|
9
|
+
it('placeholder', () => {
|
|
10
|
+
expect(true).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('no tools registered yet', () => {
|
|
16
|
+
expect(TOOLS.length).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
const EXPECTED_LOCALES = [
|
|
5
|
+
'de', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'zh'
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
describe('I18n Coverage Validation', () => {
|
|
9
|
+
it('all tools should be registered', () => {
|
|
10
|
+
expect(ALL_TOOLS.length).toBeGreaterThan(0);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
ALL_TOOLS.forEach(({ entry }: { entry: any }) => {
|
|
14
|
+
describe(`Tool: ${entry.id}`, () => {
|
|
15
|
+
it('should have all 15 required locales', () => {
|
|
16
|
+
const registeredLocales = Object.keys(entry.i18n);
|
|
17
|
+
EXPECTED_LOCALES.forEach((locale) => {
|
|
18
|
+
expect(
|
|
19
|
+
registeredLocales,
|
|
20
|
+
`Tool "${entry.id}" is missing locale "${locale}"`,
|
|
21
|
+
).toContain(locale);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('all locale loaders should be functions', () => {
|
|
26
|
+
EXPECTED_LOCALES.forEach((locale) => {
|
|
27
|
+
const loader = entry.i18n[locale as keyof typeof entry.i18n];
|
|
28
|
+
expect(
|
|
29
|
+
typeof loader,
|
|
30
|
+
`Tool "${entry.id}" locale "${locale}" loader is not a function`,
|
|
31
|
+
).toBe('function');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -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('Locale Completeness Validation', () => {
|
|
6
|
+
ALL_TOOLS.forEach((tool) => {
|
|
7
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
8
|
+
Object.keys(tool.entry.i18n).forEach((locale) => {
|
|
9
|
+
describe(`Locale: ${locale}`, () => {
|
|
10
|
+
it('bibliography should be defined when faq items exist', async () => {
|
|
11
|
+
const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
|
|
12
|
+
const content = (await loader?.()) as ToolLocaleContent;
|
|
13
|
+
|
|
14
|
+
expect(
|
|
15
|
+
content.bibliography,
|
|
16
|
+
`Tool "${tool.entry.id}" locale "${locale}" is missing bibliography`,
|
|
17
|
+
).toBeDefined();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('all tools registered', () => {
|
|
25
|
+
expect(ALL_TOOLS.length).toBe(9);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { readdirSync, readFileSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
const EXCLUDED_DIRS = ['node_modules', 'pages', 'layouts'];
|
|
6
|
+
|
|
7
|
+
function findAstroFiles(dir: string): string[] {
|
|
8
|
+
const files: string[] = [];
|
|
9
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
10
|
+
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
const fullPath = join(dir, entry.name);
|
|
13
|
+
if (entry.isDirectory() && !EXCLUDED_DIRS.includes(entry.name)) {
|
|
14
|
+
files.push(...findAstroFiles(fullPath));
|
|
15
|
+
} else if (entry.isFile() && entry.name.endsWith('.astro')) {
|
|
16
|
+
files.push(fullPath);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return files;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function hasH1(content: string): boolean {
|
|
24
|
+
return /<h1[\s>]/i.test(content);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const srcDir = join(process.cwd(), 'src');
|
|
28
|
+
const astroFiles = findAstroFiles(srcDir);
|
|
29
|
+
|
|
30
|
+
describe('No H1 in Components', () => {
|
|
31
|
+
if (astroFiles.length === 0) {
|
|
32
|
+
it('no astro components found', () => {
|
|
33
|
+
expect(true).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
astroFiles.forEach((file) => {
|
|
38
|
+
const relativePath = file.replace(process.cwd(), '');
|
|
39
|
+
it(`${relativePath} should not contain <h1>`, () => {
|
|
40
|
+
const content = readFileSync(file, 'utf-8');
|
|
41
|
+
expect(
|
|
42
|
+
hasH1(content),
|
|
43
|
+
`File "${relativePath}" contains a <h1> element. Use <h2> or lower inside components — h1 belongs to the page layout.`,
|
|
44
|
+
).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
@@ -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('Schemas Fulfillment Validation', () => {
|
|
6
|
+
ALL_TOOLS.forEach((tool) => {
|
|
7
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
8
|
+
Object.keys(tool.entry.i18n).forEach((locale) => {
|
|
9
|
+
it(`Locale: ${locale} should have faqSchema, appSchema and howToSchema`, async () => {
|
|
10
|
+
const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
|
|
11
|
+
if (!loader) return;
|
|
12
|
+
const content = (await loader()) as ToolLocaleContent;
|
|
13
|
+
|
|
14
|
+
const schemaTypes = content.schemas.map((s: any) => s['@type']);
|
|
15
|
+
|
|
16
|
+
expect(schemaTypes, `Tool "${tool.entry.id}" locale "${locale}" is missing FAQPage schema`).toContain('FAQPage');
|
|
17
|
+
expect(schemaTypes, `Tool "${tool.entry.id}" locale "${locale}" is missing SoftwareApplication schema`).toContain('SoftwareApplication');
|
|
18
|
+
expect(schemaTypes, `Tool "${tool.entry.id}" locale "${locale}" is missing HowTo schema`).toContain('HowTo');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import * as DATA from '../data';
|
|
3
|
+
|
|
4
|
+
const ENTRIES = [
|
|
5
|
+
{ id: 'chronoCategory', i18n: DATA.chronoCategory.i18n },
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
describe('SEO Content Length Validation', () => {
|
|
9
|
+
ENTRIES.forEach((entry) => {
|
|
10
|
+
describe(`Tool: ${entry.id}`, () => {
|
|
11
|
+
Object.keys(entry.i18n).forEach((locale) => {
|
|
12
|
+
it(`${locale}: SEO section should exist`, async () => {
|
|
13
|
+
const loader = (entry.i18n as Record<string, () => Promise<{ seo?: unknown[] }>>)[locale];
|
|
14
|
+
const content = await loader();
|
|
15
|
+
if (!content.seo) return;
|
|
16
|
+
expect(Array.isArray(content.seo)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../types';
|
|
2
|
+
|
|
3
|
+
export interface ToolExportValidationResult {
|
|
4
|
+
passed: boolean;
|
|
5
|
+
failures: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function validateComponentType(
|
|
9
|
+
toolId: string,
|
|
10
|
+
componentName: string,
|
|
11
|
+
component: unknown,
|
|
12
|
+
failures: string[],
|
|
13
|
+
): void {
|
|
14
|
+
if (typeof component !== 'function') {
|
|
15
|
+
failures.push(`${toolId}: ${componentName} is not a function (${typeof component})`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function validateComponentExecution(
|
|
20
|
+
toolId: string,
|
|
21
|
+
componentName: string,
|
|
22
|
+
fn: () => Promise<unknown>,
|
|
23
|
+
failures: string[],
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
try {
|
|
26
|
+
const result = await fn();
|
|
27
|
+
if (!result || typeof result !== 'object') {
|
|
28
|
+
failures.push(`${toolId}: ${componentName} import returned invalid result`);
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
failures.push(`${toolId}: ${componentName} execution error - ${error instanceof Error ? error.message : 'unknown'}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function validateToolExports(tools: ToolDefinition[]): Promise<ToolExportValidationResult> {
|
|
36
|
+
const failures: string[] = [];
|
|
37
|
+
|
|
38
|
+
for (const tool of tools) {
|
|
39
|
+
validateComponentType(tool.entry.id, 'Component', tool.Component, failures);
|
|
40
|
+
validateComponentType(tool.entry.id, 'SEOComponent', tool.SEOComponent, failures);
|
|
41
|
+
validateComponentType(tool.entry.id, 'BibliographyComponent', tool.BibliographyComponent, failures);
|
|
42
|
+
|
|
43
|
+
const componentFn = tool.Component as () => Promise<unknown>;
|
|
44
|
+
const seoFn = tool.SEOComponent as () => Promise<unknown>;
|
|
45
|
+
const bibFn = tool.BibliographyComponent as () => Promise<unknown>;
|
|
46
|
+
|
|
47
|
+
await validateComponentExecution(tool.entry.id, 'Component', componentFn, failures);
|
|
48
|
+
await validateComponentExecution(tool.entry.id, 'SEOComponent', seoFn, failures);
|
|
49
|
+
await validateComponentExecution(tool.entry.id, 'BibliographyComponent', bibFn, failures);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
passed: failures.length === 0,
|
|
54
|
+
failures,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -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(/-[a-z]{2}$/);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
import type { ToolLocaleContent } from '../types';
|
|
4
|
+
|
|
5
|
+
const sharingLocales = ['ja', 'ko', 'zh'];
|
|
6
|
+
|
|
7
|
+
interface ValidateParams {
|
|
8
|
+
toolId: string;
|
|
9
|
+
locale: string;
|
|
10
|
+
content: ToolLocaleContent;
|
|
11
|
+
enSlug: string;
|
|
12
|
+
slugs: Map<string, string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const validateLocaleSlug = ({
|
|
16
|
+
toolId,
|
|
17
|
+
locale,
|
|
18
|
+
content,
|
|
19
|
+
enSlug,
|
|
20
|
+
slugs,
|
|
21
|
+
}: ValidateParams) => {
|
|
22
|
+
expect(
|
|
23
|
+
content.slug,
|
|
24
|
+
`Tool "${toolId}" locale "${locale}" has an invalid slug ("${content.slug}"). Slugs must be transliterated (only a-z, 0-9, and -).`,
|
|
25
|
+
).toMatch(/^[a-z0-9-]+$/);
|
|
26
|
+
|
|
27
|
+
if (locale === 'en') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (sharingLocales.includes(locale)) {
|
|
32
|
+
expect(
|
|
33
|
+
content.slug,
|
|
34
|
+
`Tool "${toolId}" locale "${locale}" must use the same slug as "en" ("${enSlug}").`,
|
|
35
|
+
).toBe(enSlug);
|
|
36
|
+
} else {
|
|
37
|
+
expect(
|
|
38
|
+
content.slug,
|
|
39
|
+
`Tool "${toolId}" locale "${locale}" has the same slug as "en" ("${enSlug}"). Cada slug tiene que estar en su propia idioma`,
|
|
40
|
+
).not.toBe(enSlug);
|
|
41
|
+
|
|
42
|
+
if (slugs.has(content.slug)) {
|
|
43
|
+
const previousLocale = slugs.get(content.slug);
|
|
44
|
+
expect(
|
|
45
|
+
false,
|
|
46
|
+
`Tool "${toolId}" locales "${locale}" and "${previousLocale}" share the same slug ("${content.slug}"). Cada slug tiene que estar en su propia idioma`,
|
|
47
|
+
).toBe(true);
|
|
48
|
+
}
|
|
49
|
+
slugs.set(content.slug, locale);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe('Slug Localization and Uniqueness Validation', () => {
|
|
54
|
+
ALL_TOOLS.forEach((tool) => {
|
|
55
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
56
|
+
it('every locale should have a unique, translated slug', async () => {
|
|
57
|
+
const slugs = new Map<string, string>();
|
|
58
|
+
const locales = Object.keys(tool.entry.i18n);
|
|
59
|
+
|
|
60
|
+
let enSlug = '';
|
|
61
|
+
if (locales.includes('en')) {
|
|
62
|
+
const enLoader = tool.entry.i18n['en' as keyof typeof tool.entry.i18n];
|
|
63
|
+
const enContent = (await enLoader?.()) as ToolLocaleContent;
|
|
64
|
+
enSlug = enContent.slug;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const locale of locales) {
|
|
68
|
+
const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
|
|
69
|
+
const content = (await loader?.()) as ToolLocaleContent;
|
|
70
|
+
validateLocaleSlug({
|
|
71
|
+
toolId: tool.entry.id,
|
|
72
|
+
locale,
|
|
73
|
+
content,
|
|
74
|
+
enSlug,
|
|
75
|
+
slugs,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
function getFiles(dir: string, ext: string[]): string[] {
|
|
6
|
+
const results: string[] = [];
|
|
7
|
+
if (!fs.existsSync(dir)) return results;
|
|
8
|
+
const list = fs.readdirSync(dir);
|
|
9
|
+
for (const file of list) {
|
|
10
|
+
const fullPath = path.join(dir, file);
|
|
11
|
+
const stat = fs.statSync(fullPath);
|
|
12
|
+
if (stat && stat.isDirectory()) {
|
|
13
|
+
results.push(...getFiles(fullPath, ext));
|
|
14
|
+
} else if (ext.some((e) => file.endsWith(e))) {
|
|
15
|
+
results.push(fullPath);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return results;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SRC_DIR = path.join(process.cwd(), 'src');
|
|
22
|
+
|
|
23
|
+
describe('Project Titles - Separator Validation', () => {
|
|
24
|
+
const files = [
|
|
25
|
+
...getFiles(path.join(SRC_DIR, 'tool'), ['.ts']),
|
|
26
|
+
...getFiles(path.join(SRC_DIR, 'category'), ['.ts']),
|
|
27
|
+
].filter(f => f.includes('i18n'));
|
|
28
|
+
|
|
29
|
+
it.each(files)('Verify that titles in %s do not contain | or -', (filePath) => {
|
|
30
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
31
|
+
const relativePath = path.relative(process.cwd(), filePath);
|
|
32
|
+
|
|
33
|
+
const titlePatterns = [
|
|
34
|
+
/const\s+title\s*=\s*['"]([^'"]+)['"]/g,
|
|
35
|
+
/title\s*:\s*['"]([^'"]+)['"]/g,
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const findings: string[] = [];
|
|
39
|
+
|
|
40
|
+
for (const pattern of titlePatterns) {
|
|
41
|
+
let match;
|
|
42
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
43
|
+
const title = match[1];
|
|
44
|
+
if (title.includes('|') || title.includes('-')) {
|
|
45
|
+
findings.push(title);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (findings.length > 0) {
|
|
51
|
+
const list = findings.map((f) => ` - "${f}"`).join('\n');
|
|
52
|
+
throw new Error(`Forbidden separators (| or -) found in titles in ${relativePath}:\n${list}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|