@jjlmoya/utils-health 1.1.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 +60 -0
- package/src/category/i18n/en.ts +60 -0
- package/src/category/i18n/es.ts +60 -0
- package/src/category/i18n/fr.ts +60 -0
- package/src/category/index.ts +22 -0
- package/src/category/seo.astro +15 -0
- package/src/components/PreviewNavSidebar.astro +116 -0
- package/src/components/PreviewToolbar.astro +143 -0
- package/src/data.ts +28 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +36 -0
- package/src/layouts/PreviewLayout.astro +117 -0
- package/src/pages/[locale]/[slug].astro +146 -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/locale_completeness.test.ts +42 -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/title_quality.test.ts +55 -0
- package/src/tests/tool_validation.test.ts +17 -0
- package/src/tool/binauralTuner/bibliography.astro +14 -0
- package/src/tool/binauralTuner/component.astro +687 -0
- package/src/tool/binauralTuner/i18n/en.ts +187 -0
- package/src/tool/binauralTuner/i18n/es.ts +187 -0
- package/src/tool/binauralTuner/i18n/fr.ts +187 -0
- package/src/tool/binauralTuner/index.ts +27 -0
- package/src/tool/binauralTuner/seo.astro +14 -0
- package/src/tool/binauralTuner/ui.ts +18 -0
- package/src/tool/bloodUnitConverter/bibliography.astro +14 -0
- package/src/tool/bloodUnitConverter/component.astro +915 -0
- package/src/tool/bloodUnitConverter/i18n/en.ts +227 -0
- package/src/tool/bloodUnitConverter/i18n/es.ts +250 -0
- package/src/tool/bloodUnitConverter/i18n/fr.ts +218 -0
- package/src/tool/bloodUnitConverter/index.ts +27 -0
- package/src/tool/bloodUnitConverter/seo.astro +14 -0
- package/src/tool/bloodUnitConverter/ui.ts +38 -0
- package/src/tool/bmiCalculator/bibliography.astro +14 -0
- package/src/tool/bmiCalculator/component.astro +415 -0
- package/src/tool/bmiCalculator/i18n/en.ts +217 -0
- package/src/tool/bmiCalculator/i18n/es.ts +221 -0
- package/src/tool/bmiCalculator/i18n/fr.ts +217 -0
- package/src/tool/bmiCalculator/index.ts +27 -0
- package/src/tool/bmiCalculator/seo.astro +14 -0
- package/src/tool/bmiCalculator/ui.ts +21 -0
- package/src/tool/breathingVisualizer/bibliography.astro +14 -0
- package/src/tool/breathingVisualizer/component.astro +636 -0
- package/src/tool/breathingVisualizer/i18n/en.ts +206 -0
- package/src/tool/breathingVisualizer/i18n/es.ts +206 -0
- package/src/tool/breathingVisualizer/i18n/fr.ts +206 -0
- package/src/tool/breathingVisualizer/index.ts +27 -0
- package/src/tool/breathingVisualizer/seo.astro +14 -0
- package/src/tool/breathingVisualizer/ui.ts +31 -0
- package/src/tool/caffeineTracker/bibliography.astro +14 -0
- package/src/tool/caffeineTracker/component.astro +1210 -0
- package/src/tool/caffeineTracker/i18n/en.ts +198 -0
- package/src/tool/caffeineTracker/i18n/es.ts +198 -0
- package/src/tool/caffeineTracker/i18n/fr.ts +198 -0
- package/src/tool/caffeineTracker/index.ts +27 -0
- package/src/tool/caffeineTracker/logic.ts +31 -0
- package/src/tool/caffeineTracker/seo.astro +14 -0
- package/src/tool/caffeineTracker/ui.ts +36 -0
- package/src/tool/daltonismSimulator/bibliography.astro +14 -0
- package/src/tool/daltonismSimulator/component.astro +383 -0
- package/src/tool/daltonismSimulator/i18n/en.ts +188 -0
- package/src/tool/daltonismSimulator/i18n/es.ts +218 -0
- package/src/tool/daltonismSimulator/i18n/fr.ts +168 -0
- package/src/tool/daltonismSimulator/index.ts +27 -0
- package/src/tool/daltonismSimulator/seo.astro +14 -0
- package/src/tool/daltonismSimulator/ui.ts +20 -0
- package/src/tool/digestionStopwatch/bibliography.astro +14 -0
- package/src/tool/digestionStopwatch/component.astro +627 -0
- package/src/tool/digestionStopwatch/i18n/en.ts +173 -0
- package/src/tool/digestionStopwatch/i18n/es.ts +173 -0
- package/src/tool/digestionStopwatch/i18n/fr.ts +173 -0
- package/src/tool/digestionStopwatch/index.ts +27 -0
- package/src/tool/digestionStopwatch/logic.ts +63 -0
- package/src/tool/digestionStopwatch/seo.astro +14 -0
- package/src/tool/digestionStopwatch/ui.ts +20 -0
- package/src/tool/epworthSleepinessScale/bibliography.astro +14 -0
- package/src/tool/epworthSleepinessScale/component.astro +528 -0
- package/src/tool/epworthSleepinessScale/i18n/en.ts +217 -0
- package/src/tool/epworthSleepinessScale/i18n/es.ts +217 -0
- package/src/tool/epworthSleepinessScale/i18n/fr.ts +217 -0
- package/src/tool/epworthSleepinessScale/index.ts +27 -0
- package/src/tool/epworthSleepinessScale/seo.astro +14 -0
- package/src/tool/epworthSleepinessScale/ui.ts +27 -0
- package/src/tool/hydrationCalculator/bibliography.astro +14 -0
- package/src/tool/hydrationCalculator/component.astro +694 -0
- package/src/tool/hydrationCalculator/i18n/en.ts +217 -0
- package/src/tool/hydrationCalculator/i18n/es.ts +222 -0
- package/src/tool/hydrationCalculator/i18n/fr.ts +199 -0
- package/src/tool/hydrationCalculator/index.ts +27 -0
- package/src/tool/hydrationCalculator/seo.astro +14 -0
- package/src/tool/hydrationCalculator/ui.ts +28 -0
- package/src/tool/pelliRobsonTest/bibliography.astro +14 -0
- package/src/tool/pelliRobsonTest/component.astro +653 -0
- package/src/tool/pelliRobsonTest/i18n/en.ts +205 -0
- package/src/tool/pelliRobsonTest/i18n/es.ts +205 -0
- package/src/tool/pelliRobsonTest/i18n/fr.ts +205 -0
- package/src/tool/pelliRobsonTest/index.ts +27 -0
- package/src/tool/pelliRobsonTest/seo.astro +14 -0
- package/src/tool/pelliRobsonTest/ui.ts +21 -0
- package/src/tool/peripheralVisionTrainer/bibliography.astro +14 -0
- package/src/tool/peripheralVisionTrainer/component.astro +678 -0
- package/src/tool/peripheralVisionTrainer/i18n/en.ts +224 -0
- package/src/tool/peripheralVisionTrainer/i18n/es.ts +224 -0
- package/src/tool/peripheralVisionTrainer/i18n/fr.ts +211 -0
- package/src/tool/peripheralVisionTrainer/index.ts +27 -0
- package/src/tool/peripheralVisionTrainer/seo.astro +14 -0
- package/src/tool/peripheralVisionTrainer/ui.ts +26 -0
- package/src/tool/readingDistanceCalculator/bibliography.astro +14 -0
- package/src/tool/readingDistanceCalculator/component.astro +588 -0
- package/src/tool/readingDistanceCalculator/i18n/en.ts +202 -0
- package/src/tool/readingDistanceCalculator/i18n/es.ts +215 -0
- package/src/tool/readingDistanceCalculator/i18n/fr.ts +193 -0
- package/src/tool/readingDistanceCalculator/index.ts +31 -0
- package/src/tool/readingDistanceCalculator/seo.astro +14 -0
- package/src/tool/readingDistanceCalculator/ui.ts +18 -0
- package/src/tool/screenDecompressionTime/bibliography.astro +14 -0
- package/src/tool/screenDecompressionTime/component.astro +671 -0
- package/src/tool/screenDecompressionTime/i18n/en.ts +225 -0
- package/src/tool/screenDecompressionTime/i18n/es.ts +247 -0
- package/src/tool/screenDecompressionTime/i18n/fr.ts +225 -0
- package/src/tool/screenDecompressionTime/index.ts +27 -0
- package/src/tool/screenDecompressionTime/seo.astro +14 -0
- package/src/tool/screenDecompressionTime/ui.ts +32 -0
- package/src/tool/tinnitusReliever/bibliography.astro +14 -0
- package/src/tool/tinnitusReliever/component.astro +581 -0
- package/src/tool/tinnitusReliever/i18n/en.ts +161 -0
- package/src/tool/tinnitusReliever/i18n/es.ts +161 -0
- package/src/tool/tinnitusReliever/i18n/fr.ts +161 -0
- package/src/tool/tinnitusReliever/index.ts +27 -0
- package/src/tool/tinnitusReliever/seo.astro +14 -0
- package/src/tool/tinnitusReliever/ui.ts +9 -0
- package/src/tool/ubeCalculator/bibliography.astro +14 -0
- package/src/tool/ubeCalculator/component.astro +683 -0
- package/src/tool/ubeCalculator/i18n/en.ts +200 -0
- package/src/tool/ubeCalculator/i18n/es.ts +200 -0
- package/src/tool/ubeCalculator/i18n/fr.ts +196 -0
- package/src/tool/ubeCalculator/index.ts +27 -0
- package/src/tool/ubeCalculator/seo.astro +14 -0
- package/src/tool/ubeCalculator/ui.ts +26 -0
- package/src/tool/waterPurifier/bibliography.astro +14 -0
- package/src/tool/waterPurifier/component.astro +628 -0
- package/src/tool/waterPurifier/i18n/en.ts +167 -0
- package/src/tool/waterPurifier/i18n/es.ts +167 -0
- package/src/tool/waterPurifier/i18n/fr.ts +167 -0
- package/src/tool/waterPurifier/index.ts +27 -0
- package/src/tool/waterPurifier/seo.astro +14 -0
- package/src/tool/waterPurifier/ui.ts +18 -0
- package/src/tools.ts +19 -0
- package/src/types.ts +72 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "@jjlmoya/utils-shared/theme.css";
|
|
3
|
+
import PreviewToolbar from "../components/PreviewToolbar.astro";
|
|
4
|
+
import type { KnownLocale } from "../types";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
title: string;
|
|
8
|
+
currentLocale?: KnownLocale;
|
|
9
|
+
localeUrls?: Partial<Record<KnownLocale, string>>;
|
|
10
|
+
hasSidebar?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { title, currentLocale = "es", localeUrls = {}, hasSidebar = false } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<!doctype html>
|
|
17
|
+
<html lang={currentLocale}>
|
|
18
|
+
<head>
|
|
19
|
+
<meta charset="UTF-8" />
|
|
20
|
+
<meta name="viewport" content="width=device-width" />
|
|
21
|
+
<title>{title} · preview</title>
|
|
22
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
23
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
24
|
+
<link
|
|
25
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap"
|
|
26
|
+
rel="stylesheet"
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<script is:inline>
|
|
30
|
+
(function () {
|
|
31
|
+
const saved = localStorage.getItem("theme") || "theme-dark";
|
|
32
|
+
document.documentElement.classList.add(saved);
|
|
33
|
+
})();
|
|
34
|
+
</script>
|
|
35
|
+
<slot name="head" />
|
|
36
|
+
</head>
|
|
37
|
+
<body>
|
|
38
|
+
<PreviewToolbar currentLocale={currentLocale} localeUrls={localeUrls} />
|
|
39
|
+
<div class:list={["page-wrapper", { "with-sidebar": hasSidebar }]}>
|
|
40
|
+
{
|
|
41
|
+
hasSidebar && (
|
|
42
|
+
<aside class="sidebar-area">
|
|
43
|
+
<slot name="sidebar" />
|
|
44
|
+
</aside>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
<main>
|
|
48
|
+
<slot />
|
|
49
|
+
</main>
|
|
50
|
+
</div>
|
|
51
|
+
</body>
|
|
52
|
+
</html>
|
|
53
|
+
|
|
54
|
+
<style is:global>
|
|
55
|
+
:root {
|
|
56
|
+
--accent: #f43f5e;
|
|
57
|
+
--primary-base: #9f1239;
|
|
58
|
+
--cyan: #06b6d4;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.theme-dark,
|
|
62
|
+
.theme-light {
|
|
63
|
+
--text-main: var(--text-base);
|
|
64
|
+
--border-color: var(--border-base);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
*,
|
|
68
|
+
*::before,
|
|
69
|
+
*::after {
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
body {
|
|
74
|
+
background-color: var(--bg-page);
|
|
75
|
+
color: var(--text-base);
|
|
76
|
+
margin: 0;
|
|
77
|
+
min-height: 100vh;
|
|
78
|
+
transition:
|
|
79
|
+
background-color 0.3s ease,
|
|
80
|
+
color 0.3s ease;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main {
|
|
84
|
+
padding: 0 2rem;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.page-wrapper {
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.page-wrapper.with-sidebar {
|
|
93
|
+
display: grid;
|
|
94
|
+
grid-template-columns: 240px 1fr;
|
|
95
|
+
min-height: 100vh;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.sidebar-area {
|
|
99
|
+
position: sticky;
|
|
100
|
+
top: 0;
|
|
101
|
+
height: 100vh;
|
|
102
|
+
overflow-y: auto;
|
|
103
|
+
border-right: 1px solid var(--border-color);
|
|
104
|
+
background: var(--bg-page);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (max-width: 768px) {
|
|
108
|
+
.page-wrapper.with-sidebar {
|
|
109
|
+
grid-template-columns: 1fr;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.sidebar-area {
|
|
113
|
+
display: none;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
</style>
|
|
117
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
import PreviewLayout from "../../layouts/PreviewLayout.astro";
|
|
3
|
+
import PreviewNavSidebar from "../../components/PreviewNavSidebar.astro";
|
|
4
|
+
import { ALL_TOOLS } from "../../index";
|
|
5
|
+
import {
|
|
6
|
+
UtilityHeader,
|
|
7
|
+
FAQSection,
|
|
8
|
+
Bibliography,
|
|
9
|
+
SEORenderer,
|
|
10
|
+
} from "@jjlmoya/utils-shared";
|
|
11
|
+
import type { KnownLocale, ToolLocaleContent } from "../../types";
|
|
12
|
+
import type { UtilitySEOContent } from "@jjlmoya/utils-shared";
|
|
13
|
+
|
|
14
|
+
export async function getStaticPaths() {
|
|
15
|
+
const paths = [];
|
|
16
|
+
|
|
17
|
+
for (const { entry, Component } of ALL_TOOLS) {
|
|
18
|
+
const localeEntries = Object.entries(entry.i18n) as [
|
|
19
|
+
KnownLocale,
|
|
20
|
+
() => Promise<ToolLocaleContent>,
|
|
21
|
+
][];
|
|
22
|
+
const localeContents = await Promise.all(
|
|
23
|
+
localeEntries.map(async ([locale, loader]) => ({
|
|
24
|
+
locale,
|
|
25
|
+
content: await loader(),
|
|
26
|
+
})),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const localeUrls = Object.fromEntries(
|
|
30
|
+
localeContents.map(({ locale, content }) => [
|
|
31
|
+
locale,
|
|
32
|
+
`/${locale}/${content.slug}`,
|
|
33
|
+
]),
|
|
34
|
+
) as Partial<Record<KnownLocale, string>>;
|
|
35
|
+
|
|
36
|
+
for (const { locale, content } of localeContents) {
|
|
37
|
+
const allToolsNav = await Promise.all(
|
|
38
|
+
ALL_TOOLS.map(async ({ entry: navEntry }) => ({
|
|
39
|
+
id: navEntry.id,
|
|
40
|
+
title: (await navEntry.i18n[locale]!()).title,
|
|
41
|
+
href: `/${locale}/${(await navEntry.i18n[locale]!()).slug}`,
|
|
42
|
+
isActive: navEntry.id === entry.id,
|
|
43
|
+
})),
|
|
44
|
+
);
|
|
45
|
+
paths.push({
|
|
46
|
+
params: { locale, slug: content.slug },
|
|
47
|
+
props: { Component, locale, content, localeUrls, allToolsNav },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return paths;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type ToolComponent = (props: { ui: Record<string, string> }) => unknown;
|
|
56
|
+
|
|
57
|
+
interface NavItem {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
href: string;
|
|
61
|
+
isActive?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface Props {
|
|
65
|
+
Component: ToolComponent;
|
|
66
|
+
locale: KnownLocale;
|
|
67
|
+
content: ToolLocaleContent;
|
|
68
|
+
localeUrls: Partial<Record<KnownLocale, string>>;
|
|
69
|
+
allToolsNav: NavItem[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const { Component, locale, content, localeUrls, allToolsNav } = Astro.props;
|
|
73
|
+
|
|
74
|
+
const seoContent: UtilitySEOContent = { locale, sections: content.seo };
|
|
75
|
+
|
|
76
|
+
const words = content.title.split(" ");
|
|
77
|
+
const titleHighlight = words[0] || "";
|
|
78
|
+
const titleBase = words.slice(1).join(" ") || "";
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
<PreviewLayout
|
|
82
|
+
title={content.title}
|
|
83
|
+
currentLocale={locale}
|
|
84
|
+
localeUrls={localeUrls}
|
|
85
|
+
hasSidebar={true}
|
|
86
|
+
>
|
|
87
|
+
<PreviewNavSidebar
|
|
88
|
+
slot="sidebar"
|
|
89
|
+
categoryTitle="Tools"
|
|
90
|
+
tools={allToolsNav}
|
|
91
|
+
/>
|
|
92
|
+
<Fragment slot="head">
|
|
93
|
+
{
|
|
94
|
+
content.schemas.map((schema: unknown) => (
|
|
95
|
+
<script
|
|
96
|
+
is:inline
|
|
97
|
+
type="application/ld+json"
|
|
98
|
+
set:html={JSON.stringify(schema)}
|
|
99
|
+
/>
|
|
100
|
+
))
|
|
101
|
+
}
|
|
102
|
+
</Fragment>
|
|
103
|
+
|
|
104
|
+
<div class="tool-page">
|
|
105
|
+
<UtilityHeader
|
|
106
|
+
titleHighlight={titleHighlight}
|
|
107
|
+
titleBase={titleBase}
|
|
108
|
+
description={content.description}
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
<section class="section-tool">
|
|
112
|
+
<Component ui={content.ui} />
|
|
113
|
+
</section>
|
|
114
|
+
|
|
115
|
+
<section class="section-seo">
|
|
116
|
+
<SEORenderer content={seoContent} />
|
|
117
|
+
</section>
|
|
118
|
+
|
|
119
|
+
<section class="section-faq">
|
|
120
|
+
<FAQSection items={content.faq} title={content.ui.faqTitle} inLanguage={locale} />
|
|
121
|
+
</section>
|
|
122
|
+
|
|
123
|
+
<section class="section-bibliography">
|
|
124
|
+
<Bibliography links={content.bibliography} title={content.ui.bibliographyTitle} />
|
|
125
|
+
</section>
|
|
126
|
+
</div>
|
|
127
|
+
</PreviewLayout>
|
|
128
|
+
|
|
129
|
+
<style>
|
|
130
|
+
.tool-page {
|
|
131
|
+
display: flex;
|
|
132
|
+
flex-direction: column;
|
|
133
|
+
gap: 2rem;
|
|
134
|
+
}
|
|
135
|
+
.section-tool {
|
|
136
|
+
max-width: 1200px;
|
|
137
|
+
margin: 0 auto;
|
|
138
|
+
width: 100%;
|
|
139
|
+
}
|
|
140
|
+
.section-seo,
|
|
141
|
+
.section-faq,
|
|
142
|
+
.section-bibliography {
|
|
143
|
+
padding-top: 2rem;
|
|
144
|
+
border-top: 1px solid var(--border-color);
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
import PreviewLayout from '../layouts/PreviewLayout.astro';
|
|
3
|
+
import PreviewNavSidebar from '../components/PreviewNavSidebar.astro';
|
|
4
|
+
import { healthCategory, 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 healthCategory.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-health</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.healthCategory[] = [];
|
|
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,42 @@
|
|
|
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('faqTitle 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
|
+
if (content.faq.length > 0) {
|
|
15
|
+
expect(
|
|
16
|
+
content.faqTitle,
|
|
17
|
+
`Tool "${tool.entry.id}" locale "${locale}" has ${content.faq.length} FAQ items but is missing faqTitle`,
|
|
18
|
+
).toBeTruthy();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('bibliographyTitle should be defined when bibliography items exist', async () => {
|
|
23
|
+
const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
|
|
24
|
+
const content = (await loader?.()) as ToolLocaleContent;
|
|
25
|
+
|
|
26
|
+
if (content.bibliography.length > 0) {
|
|
27
|
+
expect(
|
|
28
|
+
content.bibliographyTitle,
|
|
29
|
+
`Tool "${tool.entry.id}" locale "${locale}" has ${content.bibliography.length} bibliography items but is missing bibliographyTitle`,
|
|
30
|
+
).toBeTruthy();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('16 tools are registered', () => {
|
|
39
|
+
expect(ALL_TOOLS.length).toBe(16);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
@@ -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: 'healthCategory', i18n: DATA.healthCategory.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
|
+
|