@jjlmoya/utils-shared 1.0.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.
@@ -0,0 +1,117 @@
1
+ ---
2
+ import { Icon } from "astro-icon/components";
3
+
4
+ interface FAQItem {
5
+ question: string;
6
+ answer: string;
7
+ }
8
+
9
+ interface Props {
10
+ items: FAQItem[];
11
+ title?: string;
12
+ inLanguage?: string;
13
+ }
14
+
15
+ const { items = [], title = "", inLanguage = "es-ES" } = Astro.props;
16
+
17
+ const faqSchema = {
18
+ "@context": "https://schema.org",
19
+ "@type": "FAQPage",
20
+ inLanguage: inLanguage,
21
+ mainEntity: items.map((item) => ({
22
+ "@type": "Question",
23
+ name: item.question,
24
+ acceptedAnswer: {
25
+ "@type": "Answer",
26
+ text: item.answer,
27
+ },
28
+ })),
29
+ };
30
+ ---
31
+
32
+ <script is:inline type="application/ld+json" set:html={JSON.stringify(faqSchema)} />
33
+
34
+ <section class="faq-section">
35
+ <h2 class="faq-title">{title}</h2>
36
+ <div class="faq-list">
37
+ {
38
+ items.map((item: FAQItem) => (
39
+ <details class="faq-item group">
40
+ <summary class="faq-question">
41
+ <span>{item.question}</span>
42
+ <Icon name="mdi:chevron-down" class="faq-icon" />
43
+ </summary>
44
+ <div class="faq-answer">{item.answer}</div>
45
+ </details>
46
+ ))
47
+ }
48
+ </div>
49
+ </section>
50
+
51
+ <style>
52
+ .faq-section {
53
+ max-width: 48rem;
54
+ margin: 4rem auto 3rem;
55
+ }
56
+
57
+ .faq-title {
58
+ font-size: 1.875rem;
59
+ font-weight: 700;
60
+ color: var(--text-base);
61
+ margin-bottom: 2rem;
62
+ text-align: center;
63
+ }
64
+
65
+ .faq-list {
66
+ display: flex;
67
+ flex-direction: column;
68
+ gap: 1.5rem;
69
+ }
70
+
71
+ .faq-item {
72
+ background-color: var(--bg-surface);
73
+ border: 1px solid var(--border-base);
74
+ border-radius: 1rem;
75
+ overflow: hidden;
76
+ transition: all 0.3s ease;
77
+ }
78
+
79
+ .faq-item:hover {
80
+ border-color: var(--accent);
81
+ box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.1);
82
+ }
83
+
84
+ .faq-question {
85
+ cursor: pointer;
86
+ padding: 1rem 1.5rem;
87
+ list-style: none;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: space-between;
91
+ font-weight: 600;
92
+ font-size: 1.125rem;
93
+ color: var(--text-base);
94
+ }
95
+
96
+ .faq-question::-webkit-details-marker {
97
+ display: none;
98
+ }
99
+
100
+ .faq-icon {
101
+ width: 1.25rem;
102
+ height: 1.25rem;
103
+ color: var(--text-dimmed);
104
+ transition: transform 0.3s ease;
105
+ }
106
+
107
+ .faq-item[open] .faq-icon {
108
+ transform: rotate(180deg);
109
+ color: var(--accent);
110
+ }
111
+
112
+ .faq-answer {
113
+ padding: 0 1.5rem 1.5rem;
114
+ color: var(--text-dimmed);
115
+ line-height: 1.6;
116
+ }
117
+ </style>
@@ -0,0 +1,83 @@
1
+ ---
2
+ interface Props {
3
+ titleHighlight: string;
4
+ titleBase: string;
5
+ description: string;
6
+ gradientFrom?: string;
7
+ gradientTo?: string;
8
+ reverse?: boolean;
9
+ }
10
+
11
+ const {
12
+ titleHighlight,
13
+ titleBase,
14
+ description,
15
+ gradientFrom = "#10b981",
16
+ gradientTo = "#0d9488",
17
+ reverse = false,
18
+ } = Astro.props;
19
+ ---
20
+
21
+ <div class="utility-header">
22
+ <h1 class="utility-header-title">
23
+ {reverse ? (
24
+ <>
25
+ <span class="utility-header-base">{titleBase}</span>
26
+ <span class="utility-header-highlight">{titleHighlight}</span>
27
+ </>
28
+ ) : (
29
+ <>
30
+ <span class="utility-header-highlight">{titleHighlight}</span>
31
+ <span class="utility-header-base">{titleBase}</span>
32
+ </>
33
+ )}
34
+ </h1>
35
+ <p class="utility-header-description">{description}</p>
36
+ </div>
37
+
38
+ <style define:vars={{ gradientFrom, gradientTo }}>
39
+ .utility-header {
40
+ text-align: center;
41
+ margin-bottom: 4rem;
42
+ }
43
+
44
+ .utility-header-title {
45
+ font-size: clamp(2.5rem, 7vw, 4.5rem);
46
+ font-weight: 900;
47
+ letter-spacing: -0.04em;
48
+ line-height: 1.1;
49
+ margin-bottom: 1.5rem;
50
+ overflow-wrap: break-word;
51
+ hyphens: auto;
52
+ display: flex;
53
+ flex-wrap: wrap;
54
+ justify-content: center;
55
+ align-items: baseline;
56
+ gap: 0.3em;
57
+ }
58
+
59
+ .utility-header-base {
60
+ color: var(--text-base);
61
+ }
62
+
63
+ .utility-header-highlight {
64
+ background: linear-gradient(to right, var(--gradientFrom), var(--gradientTo));
65
+ background-clip: text;
66
+ -webkit-text-fill-color: transparent;
67
+ }
68
+
69
+ .utility-header-description {
70
+ font-size: 1.25rem;
71
+ color: var(--text-muted);
72
+ max-width: 40rem;
73
+ margin: 0 auto;
74
+ font-weight: 300;
75
+ line-height: 1.7;
76
+ }
77
+
78
+ @media (max-width: 640px) {
79
+ .utility-header-description {
80
+ font-size: 1.1rem;
81
+ }
82
+ }
83
+ </style>
@@ -0,0 +1,149 @@
1
+ ---
2
+ interface HowToStep {
3
+ name: string;
4
+ text: string;
5
+ url?: string;
6
+ image?: string;
7
+ }
8
+
9
+ interface Props {
10
+ title: string;
11
+ description: string;
12
+ url: string;
13
+ baseUrl: string;
14
+ organizationName: string;
15
+ organizationLogo?: string;
16
+ category?: string;
17
+ howToSteps?: HowToStep[];
18
+ version?: string;
19
+ inLanguage?: string;
20
+ homeLabel?: string;
21
+ utilitiesLabel?: string;
22
+ utilitiesPath?: string;
23
+ priceCurrency?: string;
24
+ }
25
+
26
+ const {
27
+ title,
28
+ description,
29
+ url,
30
+ baseUrl,
31
+ organizationName,
32
+ organizationLogo,
33
+ category,
34
+ howToSteps,
35
+ version = "",
36
+ inLanguage = "",
37
+ homeLabel = "",
38
+ utilitiesLabel = "",
39
+ utilitiesPath = "",
40
+ priceCurrency = "",
41
+ } = Astro.props;
42
+
43
+ const fullUrl = `${baseUrl}${url}`;
44
+
45
+ const authorPublisher = {
46
+ "@type": "Person",
47
+ name: "jjlmoya",
48
+ url: baseUrl,
49
+ sameAs: [
50
+ `https://github.com/jjlmoya/`,
51
+ `https://www.linkedin.com/in/jjlmoya/`,
52
+ ],
53
+ };
54
+
55
+ const organizationSchema = {
56
+ "@context": "https://schema.org",
57
+ "@type": "Organization",
58
+ name: organizationName,
59
+ url: baseUrl,
60
+ logo: organizationLogo || `${baseUrl}/images/logo.webp`,
61
+ founder: authorPublisher,
62
+ publisher: authorPublisher,
63
+ };
64
+
65
+ const breadcrumbSchema = {
66
+ "@context": "https://schema.org",
67
+ "@type": "BreadcrumbList",
68
+ itemListElement: [
69
+ {
70
+ "@type": "ListItem",
71
+ position: 1,
72
+ name: homeLabel,
73
+ item: baseUrl,
74
+ },
75
+ {
76
+ "@type": "ListItem",
77
+ position: 2,
78
+ name: utilitiesLabel,
79
+ item: `${baseUrl}${utilitiesPath}`,
80
+ },
81
+ ...(category
82
+ ? [
83
+ {
84
+ "@type": "ListItem",
85
+ position: 3,
86
+ name: category,
87
+ item: fullUrl,
88
+ },
89
+ ]
90
+ : []),
91
+ ],
92
+ };
93
+
94
+ const webAppSchema = {
95
+ "@context": "https://schema.org",
96
+ "@type": "WebApplication",
97
+ name: title,
98
+ description: description,
99
+ url: fullUrl,
100
+ applicationCategory: "UtilityApplication",
101
+ operatingSystem: "Any",
102
+ softwareVersion: version,
103
+ author: authorPublisher,
104
+ creator: authorPublisher,
105
+ publisher: organizationSchema,
106
+ offers: {
107
+ "@type": "Offer",
108
+ price: "0",
109
+ priceCurrency: priceCurrency,
110
+ },
111
+ browserRequirements: "Requires JavaScript. Requires HTML5.",
112
+ inLanguage: inLanguage,
113
+ };
114
+
115
+ const howToSchema = {
116
+ "@context": "https://schema.org",
117
+ "@type": "HowTo",
118
+ name: title,
119
+ description: description,
120
+ inLanguage: inLanguage,
121
+ url: fullUrl,
122
+ author: authorPublisher,
123
+ publisher: organizationSchema,
124
+ ...(howToSteps && {
125
+ step: howToSteps.map((step, index) => ({
126
+ "@type": "HowToStep",
127
+ position: index + 1,
128
+ name: step.name,
129
+ text: step.text,
130
+ ...(step.url && { url: step.url }),
131
+ ...(step.image && { image: step.image }),
132
+ })),
133
+ }),
134
+ };
135
+
136
+ const isCalculator =
137
+ title.toLowerCase().includes("calc") ||
138
+ title.toLowerCase().includes("simula");
139
+
140
+ const mainSchema = isCalculator ? webAppSchema : howToSchema;
141
+
142
+ const schemas = [breadcrumbSchema, mainSchema];
143
+ ---
144
+
145
+ <script
146
+ is:inline
147
+ type="application/ld+json"
148
+ set:html={JSON.stringify(schemas)}
149
+ />