@jjlmoya/utils-travel 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 +185 -0
- package/src/category/i18n/es.ts +187 -0
- package/src/category/i18n/fr.ts +100 -0
- package/src/category/index.ts +12 -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 +15 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +22 -0
- package/src/layouts/PreviewLayout.astro +117 -0
- package/src/pages/[locale]/[slug].astro +146 -0
- package/src/pages/[locale].astro +278 -0
- package/src/pages/index.astro +4 -0
- package/src/tests/faq_count.test.ts +8 -0
- package/src/tests/locale_completeness.test.ts +21 -0
- package/src/tests/mocks/astro_mock.js +2 -0
- package/src/tests/no_h1_in_components.test.ts +8 -0
- package/src/tests/seo_length.test.ts +8 -0
- package/src/tests/tool_validation.test.ts +17 -0
- package/src/tool/luggage-calculator/bibliography.astro +14 -0
- package/src/tool/luggage-calculator/component.astro +560 -0
- package/src/tool/luggage-calculator/i18n/en.ts +617 -0
- package/src/tool/luggage-calculator/i18n/es.ts +617 -0
- package/src/tool/luggage-calculator/i18n/fr.ts +549 -0
- package/src/tool/luggage-calculator/index.ts +53 -0
- package/src/tool/luggage-calculator/seo.astro +14 -0
- package/src/tool/mini-adventures/bibliography.astro +14 -0
- package/src/tool/mini-adventures/component.astro +665 -0
- package/src/tool/mini-adventures/i18n/en.ts +161 -0
- package/src/tool/mini-adventures/i18n/es.ts +286 -0
- package/src/tool/mini-adventures/i18n/fr.ts +144 -0
- package/src/tool/mini-adventures/index.ts +70 -0
- package/src/tool/mini-adventures/seo.astro +14 -0
- package/src/tool/optimal-routes/bibliography.astro +14 -0
- package/src/tool/optimal-routes/component.astro +439 -0
- package/src/tool/optimal-routes/i18n/en.ts +42 -0
- package/src/tool/optimal-routes/i18n/es.ts +52 -0
- package/src/tool/optimal-routes/index.ts +63 -0
- package/src/tool/optimal-routes/lib/RouteManager.ts +181 -0
- package/src/tool/optimal-routes/seo.astro +14 -0
- package/src/tool/suitcase-checklist/bibliography.astro +14 -0
- package/src/tool/suitcase-checklist/component.astro +710 -0
- package/src/tool/suitcase-checklist/i18n/en.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/es.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/fr.ts +259 -0
- package/src/tool/suitcase-checklist/index.ts +75 -0
- package/src/tool/suitcase-checklist/seo.astro +14 -0
- package/src/tool/tip-calculator/bibliography.astro +14 -0
- package/src/tool/tip-calculator/component.astro +683 -0
- package/src/tool/tip-calculator/i18n/en.ts +264 -0
- package/src/tool/tip-calculator/i18n/es.ts +264 -0
- package/src/tool/tip-calculator/i18n/fr.ts +264 -0
- package/src/tool/tip-calculator/index.ts +53 -0
- package/src/tool/tip-calculator/seo.astro +14 -0
- package/src/tools.ts +13 -0
- package/src/types.ts +73 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
import PreviewLayout from "../layouts/PreviewLayout.astro";
|
|
3
|
+
import PreviewNavSidebar from "../components/PreviewNavSidebar.astro";
|
|
4
|
+
import { travelCategory, 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 travelCategory.i18n[currentLocale]!();
|
|
16
|
+
|
|
17
|
+
const tools = ALL_TOOLS || [];
|
|
18
|
+
|
|
19
|
+
const toolsWithContent =
|
|
20
|
+
tools.length > 0
|
|
21
|
+
? await Promise.all(
|
|
22
|
+
tools.map(async ({ entry, Component }) => {
|
|
23
|
+
const languages = Object.keys(entry.i18n);
|
|
24
|
+
const localeEntries = await Promise.all(
|
|
25
|
+
languages.map(async (l) => {
|
|
26
|
+
const content = await entry.i18n[l as KnownLocale]!();
|
|
27
|
+
return [l, content];
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const localeContents = Object.fromEntries(localeEntries) as Record<
|
|
32
|
+
string,
|
|
33
|
+
ToolLocaleContent<Record<string, string>>
|
|
34
|
+
>;
|
|
35
|
+
|
|
36
|
+
const currentLocaleContent =
|
|
37
|
+
localeContents[currentLocale] ||
|
|
38
|
+
localeContents["en"] ||
|
|
39
|
+
localeContents["es"];
|
|
40
|
+
const availableLocales: Record<string, string> = {};
|
|
41
|
+
|
|
42
|
+
for (const l of languages) {
|
|
43
|
+
const lCont = localeContents[l];
|
|
44
|
+
if (lCont) {
|
|
45
|
+
availableLocales[l] = `/${l}/${lCont.slug}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
entry,
|
|
51
|
+
Component,
|
|
52
|
+
locale: currentLocaleContent,
|
|
53
|
+
availableLocales,
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
56
|
+
)
|
|
57
|
+
: [];
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<PreviewLayout
|
|
61
|
+
title={categoryContent.title}
|
|
62
|
+
currentLocale={currentLocale}
|
|
63
|
+
hasSidebar={true}
|
|
64
|
+
>
|
|
65
|
+
<PreviewNavSidebar
|
|
66
|
+
slot="sidebar"
|
|
67
|
+
categoryTitle={categoryContent.title}
|
|
68
|
+
tools={toolsWithContent.map(({ entry, locale, availableLocales }) => {
|
|
69
|
+
const href =
|
|
70
|
+
availableLocales[currentLocale] ||
|
|
71
|
+
(locale ? `/${currentLocale}/${locale.slug}` : "#");
|
|
72
|
+
return {
|
|
73
|
+
id: entry.id,
|
|
74
|
+
title: locale?.title || entry.id,
|
|
75
|
+
href: href,
|
|
76
|
+
};
|
|
77
|
+
})}
|
|
78
|
+
/>
|
|
79
|
+
<div class="dashboard">
|
|
80
|
+
<header class="preview-header">
|
|
81
|
+
<span class="badge">preview · @jjlmoya/utils-template</span>
|
|
82
|
+
<h1>{categoryContent.title}</h1>
|
|
83
|
+
<p>{categoryContent.description}</p>
|
|
84
|
+
</header>
|
|
85
|
+
|
|
86
|
+
<div class="tool-list">
|
|
87
|
+
{
|
|
88
|
+
toolsWithContent?.map(({ entry, locale, availableLocales }) => (
|
|
89
|
+
<article class="tool-card">
|
|
90
|
+
<a
|
|
91
|
+
href={
|
|
92
|
+
availableLocales?.[currentLocale] ||
|
|
93
|
+
(locale ? `/${currentLocale}/${locale.slug}` : "#")
|
|
94
|
+
}
|
|
95
|
+
class="tool-card-link"
|
|
96
|
+
>
|
|
97
|
+
<div class="tool-icons">
|
|
98
|
+
<div class="icon-wrapper bg">
|
|
99
|
+
<Icon name={entry.icons.bg} />
|
|
100
|
+
</div>
|
|
101
|
+
<div class="icon-wrapper fg">
|
|
102
|
+
<Icon name={entry.icons.fg} />
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
<div class="tool-card-content">
|
|
106
|
+
<h2 class="tool-title">{locale?.title}</h2>
|
|
107
|
+
<p class="tool-description">{locale?.description}</p>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="tool-card-meta">
|
|
110
|
+
<span class="tool-id">{entry.id}</span>
|
|
111
|
+
</div>
|
|
112
|
+
</a>
|
|
113
|
+
|
|
114
|
+
{availableLocales && Object.keys(availableLocales).length > 1 && (
|
|
115
|
+
<div class="tool-locales">
|
|
116
|
+
{Object.entries(availableLocales).map(([l, url]) => (
|
|
117
|
+
<a
|
|
118
|
+
href={url}
|
|
119
|
+
class="locale-badge"
|
|
120
|
+
title={`Ver en ${l.toUpperCase()}`}
|
|
121
|
+
class:list={{ active: l === currentLocale }}
|
|
122
|
+
>
|
|
123
|
+
{l.toUpperCase()}
|
|
124
|
+
</a>
|
|
125
|
+
))}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
</article>
|
|
129
|
+
))
|
|
130
|
+
}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
</PreviewLayout>
|
|
134
|
+
|
|
135
|
+
<style>
|
|
136
|
+
.dashboard {
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
gap: 5rem;
|
|
140
|
+
}
|
|
141
|
+
.preview-header {
|
|
142
|
+
text-align: center;
|
|
143
|
+
padding-bottom: 3rem;
|
|
144
|
+
border-bottom: 1px solid var(--border-color);
|
|
145
|
+
}
|
|
146
|
+
.badge {
|
|
147
|
+
display: inline-block;
|
|
148
|
+
padding: 0.25rem 0.75rem;
|
|
149
|
+
background: var(--accent);
|
|
150
|
+
border-radius: 99px;
|
|
151
|
+
font-size: 0.7rem;
|
|
152
|
+
font-weight: 800;
|
|
153
|
+
margin-bottom: 1.5rem;
|
|
154
|
+
color: var(--text-base);
|
|
155
|
+
letter-spacing: 0.05em;
|
|
156
|
+
}
|
|
157
|
+
h1 {
|
|
158
|
+
font-size: clamp(2rem, 6vw, 3.5rem);
|
|
159
|
+
font-weight: 900;
|
|
160
|
+
margin: 0 0 1rem;
|
|
161
|
+
background: linear-gradient(to bottom, var(--text-base), var(--text-muted));
|
|
162
|
+
-webkit-background-clip: text;
|
|
163
|
+
-webkit-text-fill-color: transparent;
|
|
164
|
+
background-clip: text;
|
|
165
|
+
}
|
|
166
|
+
.preview-header p {
|
|
167
|
+
color: var(--text-muted);
|
|
168
|
+
font-size: 1.1rem;
|
|
169
|
+
margin: 0;
|
|
170
|
+
}
|
|
171
|
+
.tool-list {
|
|
172
|
+
display: grid;
|
|
173
|
+
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
|
174
|
+
gap: 2rem;
|
|
175
|
+
}
|
|
176
|
+
.tool-card {
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
gap: 1rem;
|
|
180
|
+
}
|
|
181
|
+
.tool-card-link {
|
|
182
|
+
flex: 1;
|
|
183
|
+
display: flex;
|
|
184
|
+
flex-direction: column;
|
|
185
|
+
padding: 1.5rem;
|
|
186
|
+
background: var(--bg-surface);
|
|
187
|
+
border: 1px solid var(--border-color);
|
|
188
|
+
border-radius: 0.75rem;
|
|
189
|
+
text-decoration: none;
|
|
190
|
+
transition: all 0.2s ease;
|
|
191
|
+
}
|
|
192
|
+
.tool-card-link:hover {
|
|
193
|
+
border-color: var(--accent);
|
|
194
|
+
background: rgba(244, 63, 94, 0.05);
|
|
195
|
+
transform: translateY(-2px);
|
|
196
|
+
}
|
|
197
|
+
.tool-icons {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
gap: 1rem;
|
|
201
|
+
margin-bottom: 1.25rem;
|
|
202
|
+
}
|
|
203
|
+
.icon-wrapper {
|
|
204
|
+
display: flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
width: 3rem;
|
|
208
|
+
height: 3rem;
|
|
209
|
+
border-radius: 0.5rem;
|
|
210
|
+
font-size: 1.5rem;
|
|
211
|
+
}
|
|
212
|
+
.icon-wrapper.bg {
|
|
213
|
+
background: var(--accent);
|
|
214
|
+
color: var(--text-base);
|
|
215
|
+
}
|
|
216
|
+
.icon-wrapper.fg {
|
|
217
|
+
background: var(--bg-page);
|
|
218
|
+
border: 1px solid var(--border-color);
|
|
219
|
+
color: var(--accent);
|
|
220
|
+
}
|
|
221
|
+
.tool-card-content {
|
|
222
|
+
flex: 1;
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
}
|
|
226
|
+
.tool-title {
|
|
227
|
+
font-size: 1.25rem;
|
|
228
|
+
font-weight: 700;
|
|
229
|
+
margin: 0 0 0.5rem;
|
|
230
|
+
color: var(--text-base);
|
|
231
|
+
}
|
|
232
|
+
.tool-description {
|
|
233
|
+
font-size: 0.9375rem;
|
|
234
|
+
color: var(--text-muted);
|
|
235
|
+
line-height: 1.5;
|
|
236
|
+
margin: 0;
|
|
237
|
+
}
|
|
238
|
+
.tool-card-meta {
|
|
239
|
+
padding-top: 1rem;
|
|
240
|
+
border-top: 1px solid var(--border-color);
|
|
241
|
+
margin-top: 1.5rem;
|
|
242
|
+
}
|
|
243
|
+
.tool-id {
|
|
244
|
+
display: inline-block;
|
|
245
|
+
font-size: 0.7rem;
|
|
246
|
+
background: var(--bg-page);
|
|
247
|
+
border: 1px solid var(--border-color);
|
|
248
|
+
padding: 0.35rem 0.75rem;
|
|
249
|
+
border-radius: 0.4rem;
|
|
250
|
+
color: var(--accent);
|
|
251
|
+
font-weight: 600;
|
|
252
|
+
}
|
|
253
|
+
.tool-locales {
|
|
254
|
+
display: flex;
|
|
255
|
+
gap: 0.5rem;
|
|
256
|
+
flex-wrap: wrap;
|
|
257
|
+
}
|
|
258
|
+
.locale-badge {
|
|
259
|
+
display: inline-block;
|
|
260
|
+
padding: 0.4rem 0.85rem;
|
|
261
|
+
background: var(--bg-page);
|
|
262
|
+
border: 1px solid var(--border-color);
|
|
263
|
+
border-radius: 0.4rem;
|
|
264
|
+
color: var(--text-muted);
|
|
265
|
+
text-decoration: none;
|
|
266
|
+
font-size: 0.75rem;
|
|
267
|
+
font-weight: 600;
|
|
268
|
+
text-transform: uppercase;
|
|
269
|
+
letter-spacing: 0.05em;
|
|
270
|
+
transition: all 0.15s ease;
|
|
271
|
+
}
|
|
272
|
+
.locale-badge:hover,
|
|
273
|
+
.locale-badge.active {
|
|
274
|
+
color: var(--accent);
|
|
275
|
+
border-color: var(--accent);
|
|
276
|
+
background: rgba(244, 63, 94, 0.1);
|
|
277
|
+
}
|
|
278
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
describe('Locale Completeness Validation', () => {
|
|
5
|
+
ALL_TOOLS.forEach((tool) => {
|
|
6
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
7
|
+
Object.keys(tool.entry.i18n).forEach((locale) => {
|
|
8
|
+
describe(`Locale: ${locale}`, () => {
|
|
9
|
+
it('placeholder', () => {
|
|
10
|
+
expect(true).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('tools are registered', () => {
|
|
18
|
+
expect(ALL_TOOLS.length).toBe(4);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
import { travelCategory } from '../category';
|
|
4
|
+
|
|
5
|
+
describe('Tool Validation Suite', () => {
|
|
6
|
+
describe('Library Registration', () => {
|
|
7
|
+
it('should have 4 tools in ALL_TOOLS', () => {
|
|
8
|
+
expect(ALL_TOOLS.length).toBe(4);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('travelCategory should be defined', () => {
|
|
12
|
+
expect(travelCategory).toBeDefined();
|
|
13
|
+
expect(travelCategory.i18n).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Bibliography as SharedBibliography } from "@jjlmoya/utils-shared";
|
|
3
|
+
import { luggageCalculator } from "./index";
|
|
4
|
+
import type { KnownLocale } from "../../types";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
locale?: KnownLocale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { locale = "es" } = Astro.props;
|
|
11
|
+
const content = await luggageCalculator.i18n[locale]?.();
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
{content && <SharedBibliography links={content.bibliography} />}
|