@jjlmoya/utils-nautical 1.25.0 → 1.27.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.
Files changed (37) hide show
  1. package/package.json +17 -5
  2. package/scripts/postinstall.mjs +2 -4
  3. package/src/components/ProductionBreadcrumb.astro +134 -0
  4. package/src/components/ProductionStructuredData.astro +46 -0
  5. package/src/components/ProductionWidget.astro +182 -0
  6. package/src/i18n/header-ui.ts +15 -0
  7. package/src/i18n/language-ui.ts +9 -0
  8. package/src/i18n/languages.ts +24 -0
  9. package/src/identity/brands.ts +5 -0
  10. package/src/layouts/ProductionCategoryPage.astro +184 -0
  11. package/src/layouts/ProductionPage.astro +218 -0
  12. package/src/layouts/ProductionUtilityPage.astro +283 -0
  13. package/src/mfe/assets.ts +39 -0
  14. package/src/mfe/category-ui.ts +34 -0
  15. package/src/mfe/manifest.ts +45 -0
  16. package/src/mfe/routes.ts +50 -0
  17. package/src/mfe/widget-height.ts +14 -0
  18. package/src/pages/[locale]/[utilities]/[categories]/[category]/[slug]/manifest.json.ts +49 -0
  19. package/src/pages/[locale]/[utilities]/[categories]/[category]/[slug].astro +100 -0
  20. package/src/pages/[locale]/[utilities]/[categories]/[category].astro +44 -0
  21. package/src/pages/index.astro +1 -2
  22. package/src/pages/utilidades/[slug]/manifest.json.ts +28 -0
  23. package/src/pages/utilidades/[slug].astro +90 -0
  24. package/src/pages/utilidades/categorias/[category].astro +38 -0
  25. package/src/tests/mfe_cache_contract.test.ts +11 -0
  26. package/src/tests/mfe_manifest.test.ts +28 -0
  27. package/src/tests/registry_contract.test.ts +67 -0
  28. package/src/tests/translation_copy.test.ts +2 -2
  29. package/src/tool/nauticalConverter/index.ts +1 -0
  30. package/src/tool/sailArea/index.ts +1 -0
  31. package/src/tool/speedConverter/index.ts +1 -0
  32. package/src/tool/tideCalculator/index.ts +1 -0
  33. package/src/tool/underKeel/index.ts +1 -0
  34. package/src/types.ts +4 -6
  35. package/src/worker.ts +25 -0
  36. package/src/pages/[locale]/[slug].astro +0 -161
  37. package/src/pages/[locale].astro +0 -249
@@ -1,161 +0,0 @@
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: lazyComp } of ALL_TOOLS) {
18
- const { default: Component } = await lazyComp();
19
- const localeEntries = Object.entries(entry.i18n) as [
20
- KnownLocale,
21
- () => Promise<ToolLocaleContent>,
22
- ][];
23
- const localeContents = await Promise.all(
24
- localeEntries.map(async ([locale, loader]) => ({
25
- locale,
26
- content: await loader(),
27
- })),
28
- );
29
-
30
- const localeUrls = Object.fromEntries(
31
- localeContents.map(({ locale, content }) => [
32
- locale,
33
- `/${locale}/${content.slug}`,
34
- ]),
35
- ) as Partial<Record<KnownLocale, string>>;
36
-
37
- const firstLoader = entry.i18n.en ?? Object.values(entry.i18n)[0];
38
- const englishSlug = firstLoader ? (await firstLoader()).slug : entry.id;
39
-
40
- for (const { locale, content } of localeContents) {
41
- const allToolsNav = (
42
- await Promise.all(
43
- ALL_TOOLS.map(async ({ entry: navEntry }) => {
44
- const loader = navEntry.i18n[locale] ?? navEntry.i18n.en;
45
- if (!loader) return null;
46
- const navContent = await loader();
47
- return {
48
- id: navEntry.id,
49
- title: navContent.title,
50
- href: `/${locale}/${navContent.slug}`,
51
- isActive: navEntry.id === entry.id,
52
- };
53
- }),
54
- )
55
- ).filter(Boolean) as NavItem[];
56
- paths.push({
57
- params: { locale, slug: content.slug },
58
- props: { Component, locale, content, localeUrls, allToolsNav, englishSlug },
59
- });
60
- }
61
- }
62
-
63
- return paths;
64
- }
65
-
66
- interface NavItem {
67
- id: string;
68
- title: string;
69
- href: string;
70
- isActive?: boolean;
71
- }
72
-
73
- interface Props {
74
- Component: unknown;
75
- locale: KnownLocale;
76
- content: ToolLocaleContent;
77
- localeUrls: Partial<Record<KnownLocale, string>>;
78
- allToolsNav: NavItem[];
79
- englishSlug: string;
80
- }
81
-
82
- const { Component, locale, content, localeUrls, allToolsNav, englishSlug } = Astro.props;
83
-
84
- const cssFiles = import.meta.glob("../../tool/*/*.css", { query: "?raw", import: "default" });
85
- const cssKey = Object.keys(cssFiles).find((k) => k.endsWith(`/${englishSlug}.css`));
86
- const toolCss = cssKey ? await cssFiles[cssKey]() as string : "";
87
-
88
- const seoContent: UtilitySEOContent = { locale, sections: content.seo ?? [] };
89
-
90
- const words = content.title.split(" ");
91
- const titleHighlight = words[0] || "";
92
- const titleBase = words.slice(1).join(" ") || "";
93
- ---
94
-
95
- <PreviewLayout
96
- title={content.title}
97
- currentLocale={locale}
98
- localeUrls={localeUrls}
99
- hasSidebar={true}
100
- >
101
- <PreviewNavSidebar
102
- slot="sidebar"
103
- categoryTitle="Tools"
104
- tools={allToolsNav}
105
- />
106
- <Fragment slot="head">
107
- {toolCss ? <Fragment set:html={`<style is:inline>${toolCss}</style>`} /> : null}
108
- {
109
- ( content.schemas ?? []).map((schema: unknown) => (
110
- <script
111
- is:inline
112
- type="application/ld+json"
113
- set:html={JSON.stringify(schema)}
114
- />
115
- ))
116
- }
117
- </Fragment>
118
-
119
- <div class="tool-page">
120
- <UtilityHeader
121
- titleHighlight={titleHighlight}
122
- titleBase={titleBase}
123
- description={content.description}
124
- />
125
-
126
- <section class="section-tool">
127
- <Component ui={content.ui} />
128
- </section>
129
-
130
- <section class="section-seo">
131
- <SEORenderer content={seoContent} />
132
- </section>
133
-
134
- <section class="section-faq">
135
- <FAQSection items={content.faq} title={content.ui.faqTitle} inLanguage={locale} />
136
- </section>
137
-
138
- <section class="section-bibliography">
139
- <Bibliography links={content.bibliography} title={content.ui.bibliographyTitle} />
140
- </section>
141
- </div>
142
- </PreviewLayout>
143
-
144
- <style>
145
- .tool-page {
146
- display: flex;
147
- flex-direction: column;
148
- gap: 2rem;
149
- }
150
- .section-tool {
151
- max-width: 1200px;
152
- margin: 0 auto;
153
- width: 100%;
154
- }
155
- .section-seo,
156
- .section-faq,
157
- .section-bibliography {
158
- padding-top: 2rem;
159
- border-top: 1px solid var(--border-color);
160
- }
161
- </style>
@@ -1,249 +0,0 @@
1
- ---
2
- import PreviewLayout from '../layouts/PreviewLayout.astro';
3
- import PreviewNavSidebar from '../components/PreviewNavSidebar.astro';
4
- import { 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 tools = ALL_TOOLS || [];
16
-
17
- const toolsWithContent = tools.length > 0
18
- ? await Promise.all(
19
- tools.map(async ({ entry, Component }) => {
20
- const languages = Object.keys(entry.i18n);
21
- const localeEntries = await Promise.all(
22
- languages.map(async (l) => {
23
- const content = await entry.i18n[l as KnownLocale]!();
24
- return [l, content];
25
- })
26
- );
27
-
28
- const localeContents = Object.fromEntries(localeEntries) as Record<string, ToolLocaleContent<Record<string, string>>>;
29
-
30
- const currentLocaleContent = localeContents[currentLocale] || localeContents['en'] || localeContents['es'];
31
- const availableLocales: Record<string, string> = {};
32
-
33
- for (const l of languages) {
34
- const lCont = localeContents[l];
35
- if (lCont) {
36
- availableLocales[l] = `/${l}/${lCont.slug}`;
37
- }
38
- }
39
-
40
- return { entry, Component, locale: currentLocaleContent, availableLocales };
41
- })
42
- )
43
- : [];
44
- ---
45
-
46
- <PreviewLayout
47
- title="Vela y Náutica"
48
- currentLocale={currentLocale}
49
- hasSidebar={true}
50
- >
51
- <PreviewNavSidebar
52
- slot="sidebar"
53
- categoryTitle="Vela y Náutica"
54
- tools={toolsWithContent.map(({ entry, locale, availableLocales }) => {
55
- const href = availableLocales[currentLocale] || (locale ? `/${currentLocale}/${locale.slug}` : '#');
56
- return {
57
- id: entry.id,
58
- title: locale?.title || entry.id,
59
- href: href,
60
- };
61
- })}
62
- />
63
- <div class="dashboard">
64
- <header class="preview-header">
65
- <span class="badge">preview · @jjlmoya/utils-nautical</span>
66
- <h1>Vela y Náutica</h1>
67
- <p>Herramientas de navegación y vela</p>
68
- </header>
69
-
70
- <div class="tool-list">
71
- {toolsWithContent?.map(({ entry, locale, availableLocales }) => (
72
- <article class="tool-card">
73
- <a href={availableLocales?.[currentLocale] || (locale ? `/${currentLocale}/${locale.slug}` : '#')} class="tool-card-link">
74
- <div class="tool-icons">
75
- <div class="icon-wrapper bg">
76
- <Icon name={entry.icons.bg} />
77
- </div>
78
- <div class="icon-wrapper fg">
79
- <Icon name={entry.icons.fg} />
80
- </div>
81
- </div>
82
- <div class="tool-card-content">
83
- <h2 class="tool-title">{locale?.title}</h2>
84
- <p class="tool-description">{locale?.description}</p>
85
- </div>
86
- <div class="tool-card-meta">
87
- <span class="tool-id">{entry.id}</span>
88
- </div>
89
- </a>
90
-
91
- {availableLocales && Object.keys(availableLocales).length > 1 && (
92
- <div class="tool-locales">
93
- {Object.entries(availableLocales).map(([l, url]) => (
94
- <a href={url} class="locale-badge" title={`Ver en ${l.toUpperCase()}`} class:list={{ active: l === currentLocale }}>
95
- {l.toUpperCase()}
96
- </a>
97
- ))}
98
- </div>
99
- )}
100
- </article>
101
- ))}
102
- </div>
103
- </div>
104
- </PreviewLayout>
105
-
106
- <style>
107
- .dashboard {
108
- display: flex;
109
- flex-direction: column;
110
- gap: 5rem;
111
- }
112
- .preview-header {
113
- text-align: center;
114
- padding-bottom: 3rem;
115
- border-bottom: 1px solid var(--border-color);
116
- }
117
- .badge {
118
- display: inline-block;
119
- padding: 0.25rem 0.75rem;
120
- background: var(--accent);
121
- border-radius: 99px;
122
- font-size: 0.7rem;
123
- font-weight: 800;
124
- margin-bottom: 1.5rem;
125
- color: var(--text-base);
126
- letter-spacing: 0.05em;
127
- }
128
- h1 {
129
- font-size: clamp(2rem, 6vw, 3.5rem);
130
- font-weight: 900;
131
- margin: 0 0 1rem;
132
- background: linear-gradient(to bottom, var(--text-base), var(--text-muted));
133
- -webkit-background-clip: text;
134
- -webkit-text-fill-color: transparent;
135
- background-clip: text;
136
- }
137
- .preview-header p {
138
- color: var(--text-muted);
139
- font-size: 1.1rem;
140
- margin: 0;
141
- }
142
- .tool-list {
143
- display: grid;
144
- grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
145
- gap: 2rem;
146
- }
147
- .tool-card {
148
- display: flex;
149
- flex-direction: column;
150
- gap: 1rem;
151
- }
152
- .tool-card-link {
153
- flex: 1;
154
- display: flex;
155
- flex-direction: column;
156
- padding: 1.5rem;
157
- background: var(--bg-surface);
158
- border: 1px solid var(--border-color);
159
- border-radius: 0.75rem;
160
- text-decoration: none;
161
- transition: all 0.2s ease;
162
- }
163
- .tool-card-link:hover {
164
- border-color: var(--accent);
165
- background: rgba(244, 63, 94, 0.05);
166
- transform: translateY(-2px);
167
- }
168
- .tool-icons {
169
- display: flex;
170
- align-items: center;
171
- gap: 1rem;
172
- margin-bottom: 1.25rem;
173
- }
174
- .icon-wrapper {
175
- display: flex;
176
- align-items: center;
177
- justify-content: center;
178
- width: 3rem;
179
- height: 3rem;
180
- border-radius: 0.5rem;
181
- font-size: 1.5rem;
182
- }
183
- .icon-wrapper.bg {
184
- background: var(--accent);
185
- color: var(--text-base);
186
- }
187
- .icon-wrapper.fg {
188
- background: var(--bg-page);
189
- border: 1px solid var(--border-color);
190
- color: var(--accent);
191
- }
192
- .tool-card-content {
193
- flex: 1;
194
- display: flex;
195
- flex-direction: column;
196
- }
197
- .tool-title {
198
- font-size: 1.25rem;
199
- font-weight: 700;
200
- margin: 0 0 0.5rem;
201
- color: var(--text-base);
202
- }
203
- .tool-description {
204
- font-size: 0.9375rem;
205
- color: var(--text-muted);
206
- line-height: 1.5;
207
- margin: 0;
208
- }
209
- .tool-card-meta {
210
- padding-top: 1rem;
211
- border-top: 1px solid var(--border-color);
212
- margin-top: 1.5rem;
213
- }
214
- .tool-id {
215
- display: inline-block;
216
- font-size: 0.7rem;
217
- background: var(--bg-page);
218
- border: 1px solid var(--border-color);
219
- padding: 0.35rem 0.75rem;
220
- border-radius: 0.4rem;
221
- color: var(--accent);
222
- font-weight: 600;
223
- }
224
- .tool-locales {
225
- display: flex;
226
- gap: 0.5rem;
227
- flex-wrap: wrap;
228
- }
229
- .locale-badge {
230
- display: inline-block;
231
- padding: 0.4rem 0.85rem;
232
- background: var(--bg-page);
233
- border: 1px solid var(--border-color);
234
- border-radius: 0.4rem;
235
- color: var(--text-muted);
236
- text-decoration: none;
237
- font-size: 0.75rem;
238
- font-weight: 600;
239
- text-transform: uppercase;
240
- letter-spacing: 0.05em;
241
- transition: all 0.15s ease;
242
- }
243
- .locale-badge:hover,
244
- .locale-badge.active {
245
- color: var(--accent);
246
- border-color: var(--accent);
247
- background: rgba(244, 63, 94, 0.1);
248
- }
249
- </style>