@jjlmoya/utils-shared 1.0.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjlmoya/utils-shared",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Shared SEO primitives and UI components for jjlmoya ecosystem",
5
5
  "author": "jjlmoya",
6
6
  "license": "MIT",
package/src/i18n.ts ADDED
@@ -0,0 +1,100 @@
1
+ export const languages = {
2
+ es: "Español",
3
+ en: "English",
4
+ fr: "Français",
5
+ nl: "Nederlands",
6
+ de: "Deutsch",
7
+ it: "Italiano",
8
+ pt: "Português",
9
+ ja: "日本語",
10
+ zh: "中文",
11
+ ko: "한국어",
12
+ ru: "Русский",
13
+ pl: "Polski",
14
+ tr: "Türkçe",
15
+ sv: "Svenska",
16
+ hi: "हिन्दी",
17
+ } as const;
18
+
19
+ export type Language = keyof typeof languages;
20
+
21
+ export const defaultLanguage: Language = "es";
22
+
23
+ export const translations: Record<Language, { bibliographicReferences: string; faq: string }> = {
24
+ es: {
25
+ bibliographicReferences: "Referencias Bibliográficas",
26
+ faq: "Preguntas Frecuentes",
27
+ },
28
+ en: {
29
+ bibliographicReferences: "Bibliographic References",
30
+ faq: "Frequently Asked Questions",
31
+ },
32
+ fr: {
33
+ bibliographicReferences: "Références Bibliographiques",
34
+ faq: "Questions Fréquemment Posées",
35
+ },
36
+ nl: {
37
+ bibliographicReferences: "Bibliografische Referenties",
38
+ faq: "Veelgestelde Vragen",
39
+ },
40
+ de: {
41
+ bibliographicReferences: "Bibliographische Referenzen",
42
+ faq: "Häufig Gestellte Fragen",
43
+ },
44
+ it: {
45
+ bibliographicReferences: "Riferimenti Bibliografici",
46
+ faq: "Domande Frequenti",
47
+ },
48
+ pt: {
49
+ bibliographicReferences: "Referências Bibliográficas",
50
+ faq: "Perguntas Frequentes",
51
+ },
52
+ ja: {
53
+ bibliographicReferences: "参考文献",
54
+ faq: "よくある質問",
55
+ },
56
+ zh: {
57
+ bibliographicReferences: "参考文献",
58
+ faq: "常见问题",
59
+ },
60
+ ko: {
61
+ bibliographicReferences: "참고 문헌",
62
+ faq: "자주 묻는 질문",
63
+ },
64
+ ru: {
65
+ bibliographicReferences: "Библиографические ссылки",
66
+ faq: "Часто задаваемые вопросы",
67
+ },
68
+ pl: {
69
+ bibliographicReferences: "Referencje Bibliograficzne",
70
+ faq: "Najczęściej Zadawane Pytania",
71
+ },
72
+ tr: {
73
+ bibliographicReferences: "Bibliyografik Referanslar",
74
+ faq: "Sıkça Sorulan Sorular",
75
+ },
76
+ sv: {
77
+ bibliographicReferences: "Bibliografiska Referenser",
78
+ faq: "Vanliga Frågor",
79
+ },
80
+ hi: {
81
+ bibliographicReferences: "ग्रंथ सूची संदर्भ",
82
+ faq: "अक्सर पूछे जाने वाले प्रश्न",
83
+ },
84
+ };
85
+
86
+ export const getLanguageFromUrl = (url: URL | string): Language => {
87
+ const pathname = typeof url === "string" ? url : url.pathname;
88
+ const segments = pathname.split("/").filter(Boolean);
89
+ const firstSegment = segments[0];
90
+
91
+ if (firstSegment && firstSegment in translations) {
92
+ return firstSegment as Language;
93
+ }
94
+
95
+ return defaultLanguage;
96
+ };
97
+
98
+ export const getTranslation = (language: Language, key: keyof (typeof translations)[Language]): string => {
99
+ return translations[language]?.[key] || translations[defaultLanguage][key];
100
+ };
package/src/index.ts CHANGED
@@ -22,3 +22,4 @@ export { default as UtilityHeader } from './ui/UtilityHeader.astro';
22
22
  export { default as UtilityStructuredData } from './ui/UtilityStructuredData.astro';
23
23
 
24
24
  export * from './types/index';
25
+ export * from './i18n';
@@ -20,7 +20,6 @@ import { Icon } from "astro-icon/components";
20
20
  <div class={`seo-comparative grid-cols-${columns}`}>
21
21
  {items.map((item) => (
22
22
  <div class={`comparative-card ${item.highlight ? "is-highlighted" : ""}`}>
23
- {item.highlight && <div class="highlight-badge">Recomendado</div>}
24
23
  <div class="card-header">
25
24
  {item.icon && <Icon name={item.icon} class="header-icon" />}
26
25
  <h4 class="card-title">{item.title}</h4>
@@ -78,19 +77,6 @@ import { Icon } from "astro-icon/components";
78
77
  transform: scale(1.02);
79
78
  }
80
79
 
81
- .highlight-badge {
82
- position: absolute;
83
- top: -12px;
84
- right: 24px;
85
- background: var(--accent);
86
- color: var(--text-on-accent);
87
- font-size: 0.7rem;
88
- font-weight: 800;
89
- padding: 4px 12px;
90
- border-radius: 100px;
91
- text-transform: uppercase;
92
- letter-spacing: 0.05em;
93
- }
94
80
 
95
81
  .card-header {
96
82
  display: flex;
@@ -16,7 +16,6 @@ const { title, items } = Astro.props;
16
16
  <Icon name="mdi:lightbulb-on-outline" class="header-icon" />
17
17
  </div>
18
18
  <div class="header-text">
19
- <span class="header-subtitle">Resumen </span>
20
19
  <h4 class="header-title">{title}</h4>
21
20
  </div>
22
21
  </div>
@@ -87,14 +86,6 @@ const { title, items } = Astro.props;
87
86
  flex-direction: column;
88
87
  }
89
88
 
90
- .header-subtitle {
91
- font-size: 0.65rem;
92
- font-weight: 800;
93
- color: var(--text-dimmed);
94
- text-transform: uppercase;
95
- letter-spacing: 0.1em;
96
- }
97
-
98
89
  .header-title {
99
90
  font-size: 1.25rem;
100
91
  font-weight: 800;
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import { Icon } from "astro-icon/components";
3
+ import { getLanguageFromUrl, getTranslation } from "../i18n";
3
4
 
4
5
  interface Link {
5
6
  name: string;
@@ -8,10 +9,12 @@ interface Link {
8
9
 
9
10
  interface Props {
10
11
  links: Link[];
11
- title?: string;
12
12
  }
13
13
 
14
- const { links = [], title = "Referencias Bibliográficas" } = Astro.props;
14
+ const { links = [] } = Astro.props;
15
+
16
+ const language = getLanguageFromUrl(Astro.url);
17
+ const title = getTranslation(language, "bibliographicReferences");
15
18
  ---
16
19
 
17
20
  <div class="bibliography">
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import { Icon } from "astro-icon/components";
3
+ import { getLanguageFromUrl, getTranslation } from "../i18n";
3
4
 
4
5
  interface FAQItem {
5
6
  question: string;
@@ -8,11 +9,13 @@ interface FAQItem {
8
9
 
9
10
  interface Props {
10
11
  items: FAQItem[];
11
- title?: string;
12
- inLanguage?: string;
13
12
  }
14
13
 
15
- const { items = [], title = "", inLanguage = "es-ES" } = Astro.props;
14
+ const { items = [] } = Astro.props;
15
+
16
+ const language = getLanguageFromUrl(Astro.url);
17
+ const title = getTranslation(language, "faq");
18
+ const inLanguage = language === "es" ? "es-ES" : `${language}-${language.toUpperCase()}`;
16
19
 
17
20
  const faqSchema = {
18
21
  "@context": "https://schema.org",