astro-blog-kit 0.3.6 → 0.3.7
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/components/Pagination.astro +17 -17
- package/integration.ts +36 -27
- package/package.json +1 -1
- package/types.ts +18 -70
|
@@ -12,8 +12,8 @@ const pages = Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
|
12
12
|
<nav class="pagination" aria-label="Blog pagination">
|
|
13
13
|
|
|
14
14
|
{currentPage > 1 && (
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
<a
|
|
16
|
+
href={currentPage === 2 ? blogBase : `${basePath}${currentPage - 1}/`}
|
|
17
17
|
class="pagination__btn"
|
|
18
18
|
>
|
|
19
19
|
← {t.blog.btn_prev}
|
|
@@ -22,8 +22,8 @@ const pages = Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
|
22
22
|
|
|
23
23
|
<div class="pagination__pages">
|
|
24
24
|
{pages.map((pageNum) => (
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
<a
|
|
26
|
+
href={pageNum === 1 ? blogBase : `${basePath}${pageNum}/`}
|
|
27
27
|
class={`pagination__page ${pageNum === currentPage ? "pagination__page--active" : ""}`}
|
|
28
28
|
aria-current={pageNum === currentPage ? "page" : undefined}
|
|
29
29
|
>
|
|
@@ -49,25 +49,25 @@ const pages = Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
|
49
49
|
gap: 0.75rem;
|
|
50
50
|
flex-wrap: wrap;
|
|
51
51
|
padding-top: 3rem;
|
|
52
|
-
border-top: 2px solid var(--bk-
|
|
52
|
+
border-top: 2px solid var(--bk-border);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.pagination__btn {
|
|
56
56
|
padding: 0.6rem 1.25rem;
|
|
57
|
-
background-color: var(--bk-
|
|
58
|
-
color: var(--bk-
|
|
57
|
+
background-color: var(--bk-pagination-btn-bg);
|
|
58
|
+
color: var(--bk-pagination-btn-text);
|
|
59
59
|
font-family: var(--bk-font-heading);
|
|
60
60
|
font-size: 0.9rem;
|
|
61
61
|
font-weight: 700;
|
|
62
62
|
text-transform: uppercase;
|
|
63
63
|
letter-spacing: 0.08em;
|
|
64
64
|
text-decoration: none;
|
|
65
|
-
transition:
|
|
65
|
+
transition: var(--bk-transition);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
.pagination__btn:hover {
|
|
69
|
-
background-color: var(--bk-
|
|
70
|
-
color: var(--bk-
|
|
69
|
+
background-color: var(--bk-pagination-btn-hover-bg);
|
|
70
|
+
color: var(--bk-pagination-btn-hover-text);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
.pagination__pages {
|
|
@@ -83,19 +83,19 @@ const pages = Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
|
83
83
|
font-weight: 700;
|
|
84
84
|
font-size: 0.9rem;
|
|
85
85
|
color: var(--bk-muted);
|
|
86
|
-
border: 2px solid var(--bk-
|
|
86
|
+
border: 2px solid var(--bk-border);
|
|
87
87
|
text-decoration: none;
|
|
88
|
-
transition:
|
|
88
|
+
transition: var(--bk-transition);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.pagination__page:hover {
|
|
92
|
-
border-color: var(--bk-
|
|
93
|
-
color: var(--bk-
|
|
92
|
+
border-color: var(--bk-pagination-btn-bg);
|
|
93
|
+
color: var(--bk-text);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
.pagination__page--active {
|
|
97
|
-
background-color: var(--bk-
|
|
98
|
-
border-color: var(--bk-
|
|
99
|
-
color: var(--bk-
|
|
97
|
+
background-color: var(--bk-pagination-active-bg);
|
|
98
|
+
border-color: var(--bk-pagination-active-bg);
|
|
99
|
+
color: var(--bk-pagination-active-text);
|
|
100
100
|
}
|
|
101
101
|
</style>
|
package/integration.ts
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import type { AstroIntegration } from "astro";
|
|
6
6
|
import type { Plugin } from "vite";
|
|
7
|
-
import type { BlogKitConfig, BlogTheme } from "./types";
|
|
7
|
+
import type { BlogKitConfig, BlogTheme, BlogUI } from "./types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Genera el bloque de CSS variables a partir del tema.
|
|
10
|
+
* Genera el bloque de CSS variables a partir del tema y la UI.
|
|
11
11
|
*/
|
|
12
|
-
function generateThemeCSS(theme: BlogTheme = {}): string {
|
|
12
|
+
function generateThemeCSS(theme: BlogTheme = {}, ui: BlogUI = {}): string {
|
|
13
13
|
const t = {
|
|
14
14
|
accent: theme.accent ?? "#facc15",
|
|
15
15
|
background: theme.background ?? "#ffffff",
|
|
@@ -29,27 +29,35 @@ function generateThemeCSS(theme: BlogTheme = {}): string {
|
|
|
29
29
|
|
|
30
30
|
return [
|
|
31
31
|
":root {",
|
|
32
|
-
` --bk-accent:
|
|
33
|
-
` --bk-background:
|
|
34
|
-
` --bk-surface:
|
|
35
|
-
` --bk-text:
|
|
36
|
-
` --bk-muted:
|
|
37
|
-
` --bk-muted-light:
|
|
38
|
-
` --bk-border:
|
|
39
|
-
` --bk-black:
|
|
40
|
-
` --bk-white:
|
|
41
|
-
` --bk-yellow:
|
|
42
|
-
` --bk-gray-100:
|
|
43
|
-
` --bk-gray-200:
|
|
44
|
-
` --bk-gray-300:
|
|
45
|
-
` --bk-gray-400:
|
|
46
|
-
` --bk-gray-600:
|
|
47
|
-
` --bk-font-heading:
|
|
48
|
-
` --bk-font-body:
|
|
49
|
-
` --bk-font-mono:
|
|
50
|
-
` --bk-font-display:
|
|
51
|
-
` --bk-container-max:
|
|
52
|
-
` --bk-transition:
|
|
32
|
+
` --bk-accent: ${t.accent};`,
|
|
33
|
+
` --bk-background: ${t.background};`,
|
|
34
|
+
` --bk-surface: ${t.surface};`,
|
|
35
|
+
` --bk-text: ${t.text};`,
|
|
36
|
+
` --bk-muted: ${t.muted};`,
|
|
37
|
+
` --bk-muted-light: ${t.mutedLight};`,
|
|
38
|
+
` --bk-border: ${t.border};`,
|
|
39
|
+
` --bk-black: ${t.black};`,
|
|
40
|
+
` --bk-white: ${t.white};`,
|
|
41
|
+
` --bk-yellow: ${t.accent};`,
|
|
42
|
+
` --bk-gray-100: #f3f4f6;`,
|
|
43
|
+
` --bk-gray-200: #e5e7eb;`,
|
|
44
|
+
` --bk-gray-300: #d1d5db;`,
|
|
45
|
+
` --bk-gray-400: #9ca3af;`,
|
|
46
|
+
` --bk-gray-600: #4b5563;`,
|
|
47
|
+
` --bk-font-heading: ${t.fontHeading};`,
|
|
48
|
+
` --bk-font-body: ${t.fontBody};`,
|
|
49
|
+
` --bk-font-mono: ${t.fontMono};`,
|
|
50
|
+
` --bk-font-display: ${t.fontDisplay};`,
|
|
51
|
+
` --bk-container-max: ${t.containerMax};`,
|
|
52
|
+
` --bk-transition: all 0.2s ease;`,
|
|
53
|
+
` --bk-pagination-btn-bg: ${ui.paginationBtnBg ?? t.accent};`,
|
|
54
|
+
` --bk-pagination-btn-text: ${ui.paginationBtnText ?? t.black};`,
|
|
55
|
+
` --bk-pagination-btn-hover-bg: ${ui.paginationBtnHoverBg ?? t.text};`,
|
|
56
|
+
` --bk-pagination-btn-hover-text: ${ui.paginationBtnHoverText ?? t.white};`,
|
|
57
|
+
` --bk-pagination-active-bg: ${ui.paginationActiveBg ?? t.accent};`,
|
|
58
|
+
` --bk-pagination-active-text: ${ui.paginationActiveText ?? t.black};`,
|
|
59
|
+
` --bk-comment-btn-bg: ${ui.commentButtonColor ?? t.accent};`,
|
|
60
|
+
` --bk-comment-btn-text: ${ui.commentButtonTextColor ?? t.black};`,
|
|
53
61
|
"}",
|
|
54
62
|
].join("\n");
|
|
55
63
|
}
|
|
@@ -58,9 +66,9 @@ function generateThemeCSS(theme: BlogTheme = {}): string {
|
|
|
58
66
|
* Plugin de Vite que inyecta el CSS del tema como módulo CSS real,
|
|
59
67
|
* compatible con Rolldown (Astro 7+).
|
|
60
68
|
*/
|
|
61
|
-
function createThemePlugin(theme: BlogTheme): Plugin {
|
|
69
|
+
function createThemePlugin(theme: BlogTheme, ui: BlogUI): Plugin {
|
|
62
70
|
const THEME_ID = "\0astro-blog-kit-theme.css";
|
|
63
|
-
const css = generateThemeCSS(theme);
|
|
71
|
+
const css = generateThemeCSS(theme, ui);
|
|
64
72
|
|
|
65
73
|
return {
|
|
66
74
|
name: "astro-blog-kit:theme",
|
|
@@ -109,9 +117,10 @@ export function blogKit(config: BlogKitConfig = {}): AstroIntegration {
|
|
|
109
117
|
`astro-blog-kit initialized — layout: ${resolvedConfig.defaultLayout}, postsPerPage: ${resolvedConfig.postsPerPage}`
|
|
110
118
|
);
|
|
111
119
|
|
|
120
|
+
// Pasa tanto theme como ui al plugin
|
|
112
121
|
updateConfig({
|
|
113
122
|
vite: {
|
|
114
|
-
plugins: [createThemePlugin(resolvedConfig.theme)],
|
|
123
|
+
plugins: [createThemePlugin(resolvedConfig.theme, resolvedConfig.ui)],
|
|
115
124
|
},
|
|
116
125
|
});
|
|
117
126
|
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -2,32 +2,17 @@
|
|
|
2
2
|
// astro-blog-kit · types.ts
|
|
3
3
|
// ─────────────────────────────────────────────────────────────
|
|
4
4
|
|
|
5
|
-
// ── Post ──────────────────────────────────────────────────────
|
|
6
|
-
|
|
7
5
|
export interface BlogPost {
|
|
8
6
|
id?: number;
|
|
9
7
|
slug: string;
|
|
10
8
|
date: string;
|
|
11
9
|
modified?: string;
|
|
12
|
-
title: {
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
excerpt: {
|
|
16
|
-
rendered: string;
|
|
17
|
-
};
|
|
18
|
-
content: {
|
|
19
|
-
rendered: string;
|
|
20
|
-
};
|
|
10
|
+
title: { rendered: string };
|
|
11
|
+
excerpt: { rendered: string };
|
|
12
|
+
content: { rendered: string };
|
|
21
13
|
_embedded?: {
|
|
22
|
-
"wp:featuredmedia"?: Array<{
|
|
23
|
-
|
|
24
|
-
alt_text?: string;
|
|
25
|
-
}>;
|
|
26
|
-
"wp:term"?: {
|
|
27
|
-
id: number;
|
|
28
|
-
name: string;
|
|
29
|
-
slug: string;
|
|
30
|
-
}[][];
|
|
14
|
+
"wp:featuredmedia"?: Array<{ source_url: string; alt_text?: string }>;
|
|
15
|
+
"wp:term"?: { id: number; name: string; slug: string }[][];
|
|
31
16
|
};
|
|
32
17
|
heroImage?: string;
|
|
33
18
|
lang?: string;
|
|
@@ -35,12 +20,8 @@ export interface BlogPost {
|
|
|
35
20
|
readingTime?: number;
|
|
36
21
|
}
|
|
37
22
|
|
|
38
|
-
// ── Layouts ───────────────────────────────────────────────────
|
|
39
|
-
|
|
40
23
|
export type BlogListLayout = "grid" | "magazine" | "featured" | "cards";
|
|
41
24
|
|
|
42
|
-
// ── i18n ──────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
25
|
export interface I18nConfig {
|
|
45
26
|
locales: string[];
|
|
46
27
|
defaultLocale: string;
|
|
@@ -58,8 +39,6 @@ export interface BlogTranslations {
|
|
|
58
39
|
};
|
|
59
40
|
}
|
|
60
41
|
|
|
61
|
-
// ── Paginación ────────────────────────────────────────────────
|
|
62
|
-
|
|
63
42
|
export interface PaginationProps {
|
|
64
43
|
currentPage: number;
|
|
65
44
|
totalPages: number;
|
|
@@ -68,8 +47,6 @@ export interface PaginationProps {
|
|
|
68
47
|
t: BlogTranslations;
|
|
69
48
|
}
|
|
70
49
|
|
|
71
|
-
// ── BlogList ──────────────────────────────────────────────────
|
|
72
|
-
|
|
73
50
|
export interface BlogListProps {
|
|
74
51
|
posts: BlogPost[];
|
|
75
52
|
currentPage: number;
|
|
@@ -79,66 +56,39 @@ export interface BlogListProps {
|
|
|
79
56
|
dateLocale: string;
|
|
80
57
|
t: BlogTranslations;
|
|
81
58
|
locale: string;
|
|
82
|
-
/** @default "magazine" */
|
|
83
59
|
layout?: BlogListLayout;
|
|
84
60
|
}
|
|
85
61
|
|
|
86
|
-
// ── BlogPost componente ───────────────────────────────────────
|
|
87
|
-
|
|
88
62
|
export interface BlogPostProps {
|
|
89
63
|
post: BlogPost;
|
|
90
64
|
t: BlogTranslations;
|
|
91
65
|
lang: string;
|
|
92
66
|
}
|
|
93
67
|
|
|
94
|
-
// ── Tema ──────────────────────────────────────────────────────
|
|
95
|
-
|
|
96
68
|
export interface BlogTheme {
|
|
97
|
-
/** Color de acento principal. @default "#facc15" */
|
|
98
69
|
accent?: string;
|
|
99
|
-
/** Color de fondo. @default "#ffffff" */
|
|
100
70
|
background?: string;
|
|
101
|
-
/** Color de superficie (cards, sidebars). @default "#f8f8f8" */
|
|
102
71
|
surface?: string;
|
|
103
|
-
/** Color de texto principal. @default "#0a0a0a" */
|
|
104
72
|
text?: string;
|
|
105
|
-
/** Color de texto secundario. @default "#6b7280" */
|
|
106
73
|
muted?: string;
|
|
107
|
-
/** Color de texto secundario claro. @default "#9ca3af" */
|
|
108
74
|
mutedLight?: string;
|
|
109
|
-
/** Color de bordes. @default "#e5e7eb" */
|
|
110
75
|
border?: string;
|
|
111
|
-
/** Color negro para layouts. @default "#0a0a0a" */
|
|
112
76
|
black?: string;
|
|
113
|
-
/** Color blanco para layouts. @default "#ffffff" */
|
|
114
77
|
white?: string;
|
|
115
|
-
/** Fuente de títulos. @default "Georgia, serif" */
|
|
116
78
|
fontHeading?: string;
|
|
117
|
-
/** Fuente de cuerpo. @default "system-ui, sans-serif" */
|
|
118
79
|
fontBody?: string;
|
|
119
|
-
/** Fuente monospace. @default "monospace" */
|
|
120
80
|
fontMono?: string;
|
|
121
|
-
/** Fuente display (títulos grandes). @default "Georgia, serif" */
|
|
122
81
|
fontDisplay?: string;
|
|
123
|
-
/** Ancho máximo del contenedor. @default "1200px" */
|
|
124
82
|
containerMax?: string;
|
|
125
83
|
}
|
|
126
84
|
|
|
127
|
-
// ── Hero del blog ─────────────────────────────────────────────
|
|
128
|
-
|
|
129
85
|
export interface BlogHero {
|
|
130
|
-
/** Texto del badge superior. @default "Our Blog" */
|
|
131
86
|
tagline?: string;
|
|
132
|
-
/** Primera línea del título. @default "Latest" */
|
|
133
87
|
titleLine1?: string;
|
|
134
|
-
/** Segunda línea del título (resaltada). @default "Articles" */
|
|
135
88
|
titleLine2?: string;
|
|
136
|
-
/** Párrafo descriptivo debajo del título. @default "Welcome to our blog." */
|
|
137
89
|
description?: string;
|
|
138
90
|
}
|
|
139
91
|
|
|
140
|
-
// ── UI overrides ──────────────────────────────────────────────
|
|
141
|
-
|
|
142
92
|
export interface BlogUI {
|
|
143
93
|
/** Texto del botón "leer más". @default "Read more →" */
|
|
144
94
|
readMoreLabel?: string;
|
|
@@ -152,35 +102,33 @@ export interface BlogUI {
|
|
|
152
102
|
commentButtonTextColor?: string;
|
|
153
103
|
/** Estilo de paginación. @default "minimal" */
|
|
154
104
|
paginationStyle?: "minimal" | "numbered";
|
|
105
|
+
/** Fondo botones PREV/NEXT. @default accent */
|
|
106
|
+
paginationBtnBg?: string;
|
|
107
|
+
/** Texto botones PREV/NEXT. @default black */
|
|
108
|
+
paginationBtnText?: string;
|
|
109
|
+
/** Fondo botones PREV/NEXT en hover. @default text */
|
|
110
|
+
paginationBtnHoverBg?: string;
|
|
111
|
+
/** Texto botones PREV/NEXT en hover. @default white */
|
|
112
|
+
paginationBtnHoverText?: string;
|
|
113
|
+
/** Fondo página activa. @default accent */
|
|
114
|
+
paginationActiveBg?: string;
|
|
115
|
+
/** Texto página activa. @default black */
|
|
116
|
+
paginationActiveText?: string;
|
|
155
117
|
}
|
|
156
118
|
|
|
157
|
-
// ── Config del paquete ────────────────────────────────────────
|
|
158
|
-
|
|
159
119
|
export interface BlogKitConfig {
|
|
160
|
-
/** @default 5 */
|
|
161
120
|
postsPerPage?: number;
|
|
162
121
|
i18n?: I18nConfig;
|
|
163
|
-
/** @default "magazine" */
|
|
164
122
|
defaultLayout?: BlogListLayout;
|
|
165
|
-
/** @default "blog" */
|
|
166
123
|
collectionName?: string;
|
|
167
|
-
/** Tema visual del blog */
|
|
168
124
|
theme?: BlogTheme;
|
|
169
|
-
/** Textos del hero/header del blog */
|
|
170
125
|
hero?: BlogHero;
|
|
171
|
-
/** Overrides de UI (botones, paginación, labels) */
|
|
172
126
|
ui?: BlogUI;
|
|
173
127
|
}
|
|
174
128
|
|
|
175
|
-
// ── getStaticPaths ────────────────────────────────────────────
|
|
176
|
-
|
|
177
129
|
export interface PageStaticPath {
|
|
178
130
|
params: { page: string };
|
|
179
|
-
props: {
|
|
180
|
-
posts: BlogPost[];
|
|
181
|
-
currentPage: number;
|
|
182
|
-
totalPages: number;
|
|
183
|
-
};
|
|
131
|
+
props: { posts: BlogPost[]; currentPage: number; totalPages: number };
|
|
184
132
|
}
|
|
185
133
|
|
|
186
134
|
export interface PostStaticPath {
|