astro-blog-kit 0.2.0 → 0.2.2
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/bin/cli.js +19 -2
- package/cli.ts +19 -1
- package/package.json +1 -1
- package/templates/blog-index.astro.template +15 -22
- package/templates/blog-page.astro.template +14 -21
- package/templates/blog-slug.astro.template +6 -12
package/bin/cli.js
CHANGED
|
@@ -42,6 +42,10 @@ async function main() {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}),
|
|
45
|
+
layoutComponent: () => p.text({
|
|
46
|
+
message: "Layout component path (leave empty to skip)",
|
|
47
|
+
placeholder: "../../layouts/Layout.astro"
|
|
48
|
+
}),
|
|
45
49
|
postsPerPage: () => p.text({
|
|
46
50
|
message: "Posts per page",
|
|
47
51
|
placeholder: "5",
|
|
@@ -53,10 +57,12 @@ async function main() {
|
|
|
53
57
|
}),
|
|
54
58
|
defaultLayout: () => p.select({
|
|
55
59
|
message: "Default layout",
|
|
60
|
+
// DESPUÉS
|
|
56
61
|
options: [
|
|
57
62
|
{ value: "magazine", label: "Magazine \u2014 featured post + grid" },
|
|
58
63
|
{ value: "grid", label: "Grid \u2014 3 column card grid" },
|
|
59
|
-
{ value: "
|
|
64
|
+
{ value: "featured", label: "Featured \u2014 large hero + grid below" },
|
|
65
|
+
{ value: "cards", label: "Cards \u2014 image background + text overlay" }
|
|
60
66
|
]
|
|
61
67
|
}),
|
|
62
68
|
locale: () => p.text({
|
|
@@ -76,11 +82,22 @@ async function main() {
|
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
);
|
|
85
|
+
const layoutPath = answers.layoutComponent || "";
|
|
79
86
|
const replacements = {
|
|
80
87
|
WP_URL: answers.wpUrl,
|
|
81
88
|
POSTS_PER_PAGE: answers.postsPerPage,
|
|
82
89
|
DEFAULT_LAYOUT: answers.defaultLayout,
|
|
83
|
-
LOCALE: answers.locale
|
|
90
|
+
LOCALE: answers.locale,
|
|
91
|
+
LAYOUT_IMPORT: layoutPath ? `import Layout from "${layoutPath}";` : "",
|
|
92
|
+
LAYOUT_OPEN: layoutPath ? `<Layout>` : `<html lang={config.locale ?? "en"}>
|
|
93
|
+
<head>
|
|
94
|
+
<meta charset="UTF-8" />
|
|
95
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
96
|
+
<title>Blog</title>
|
|
97
|
+
</head>
|
|
98
|
+
<body>`,
|
|
99
|
+
LAYOUT_CLOSE: layoutPath ? `</Layout>` : ` </body>
|
|
100
|
+
</html>`
|
|
84
101
|
};
|
|
85
102
|
const cwd = process.cwd();
|
|
86
103
|
const spinner2 = p.spinner();
|
package/cli.ts
CHANGED
|
@@ -65,6 +65,11 @@ async function main() {
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
}),
|
|
68
|
+
layoutComponent: () =>
|
|
69
|
+
p.text({
|
|
70
|
+
message: "Layout component path (leave empty to skip)",
|
|
71
|
+
placeholder: "../../layouts/Layout.astro",
|
|
72
|
+
}),
|
|
68
73
|
|
|
69
74
|
postsPerPage: () =>
|
|
70
75
|
p.text({
|
|
@@ -80,10 +85,12 @@ async function main() {
|
|
|
80
85
|
defaultLayout: () =>
|
|
81
86
|
p.select({
|
|
82
87
|
message: "Default layout",
|
|
88
|
+
// DESPUÉS
|
|
83
89
|
options: [
|
|
84
90
|
{ value: "magazine", label: "Magazine — featured post + grid" },
|
|
85
91
|
{ value: "grid", label: "Grid — 3 column card grid" },
|
|
86
|
-
{ value: "
|
|
92
|
+
{ value: "featured", label: "Featured — large hero + grid below" },
|
|
93
|
+
{ value: "cards", label: "Cards — image background + text overlay" },
|
|
87
94
|
],
|
|
88
95
|
}),
|
|
89
96
|
|
|
@@ -110,11 +117,22 @@ async function main() {
|
|
|
110
117
|
|
|
111
118
|
// ── Replacements ──────────────────────────────────────────
|
|
112
119
|
|
|
120
|
+
const layoutPath = (answers.layoutComponent as string) || "";
|
|
121
|
+
|
|
113
122
|
const replacements: Record<string, string> = {
|
|
114
123
|
WP_URL: answers.wpUrl as string,
|
|
115
124
|
POSTS_PER_PAGE: answers.postsPerPage as string,
|
|
116
125
|
DEFAULT_LAYOUT: answers.defaultLayout as string,
|
|
117
126
|
LOCALE: answers.locale as string,
|
|
127
|
+
LAYOUT_IMPORT: layoutPath
|
|
128
|
+
? `import Layout from "${layoutPath}";`
|
|
129
|
+
: "",
|
|
130
|
+
LAYOUT_OPEN: layoutPath
|
|
131
|
+
? `<Layout>`
|
|
132
|
+
: `<html lang={config.locale ?? "en"}>\n <head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>Blog</title>\n </head>\n <body>`,
|
|
133
|
+
LAYOUT_CLOSE: layoutPath
|
|
134
|
+
? `</Layout>`
|
|
135
|
+
: ` </body>\n</html>`,
|
|
118
136
|
};
|
|
119
137
|
|
|
120
138
|
// ── Copia archivos ────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { BlogList } from "astro-blog-kit/components";
|
|
3
3
|
import { createWPClient } from "astro-blog-kit/utils";
|
|
4
|
-
import config from "
|
|
4
|
+
import config from "../../../../blog.config";
|
|
5
|
+
__LAYOUT_IMPORT__
|
|
5
6
|
|
|
6
7
|
const wp = createWPClient(config.wpUrl);
|
|
7
8
|
const { posts, totalPages } = await wp.getPosts({ perPage: config.postsPerPage ?? 5 });
|
|
@@ -21,24 +22,16 @@ const t = {
|
|
|
21
22
|
const base = import.meta.env.BASE_URL;
|
|
22
23
|
---
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
blogBase={`${base}blog/`}
|
|
38
|
-
dateLocale={config.locale ?? "en"}
|
|
39
|
-
t={t}
|
|
40
|
-
locale={config.locale ?? "en"}
|
|
41
|
-
layout={config.defaultLayout ?? "magazine"}
|
|
42
|
-
/>
|
|
43
|
-
</body>
|
|
44
|
-
</html>
|
|
25
|
+
__LAYOUT_OPEN__
|
|
26
|
+
<BlogList
|
|
27
|
+
posts={posts}
|
|
28
|
+
currentPage={1}
|
|
29
|
+
totalPages={totalPages}
|
|
30
|
+
basePath={`${base}blog/page/`}
|
|
31
|
+
blogBase={`${base}blog/`}
|
|
32
|
+
dateLocale={config.locale ?? "en"}
|
|
33
|
+
t={t}
|
|
34
|
+
locale={config.locale ?? "en"}
|
|
35
|
+
layout={config.defaultLayout ?? "magazine"}
|
|
36
|
+
/>
|
|
37
|
+
__LAYOUT_CLOSE__
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { BlogList } from "astro-blog-kit/components";
|
|
3
3
|
import { createWPClient, getStaticPathsForPages } from "astro-blog-kit/utils";
|
|
4
4
|
import config from "../../../../blog.config";
|
|
5
|
+
__LAYOUT_IMPORT__
|
|
5
6
|
|
|
6
7
|
export async function getStaticPaths() {
|
|
7
8
|
const wp = createWPClient(config.wpUrl);
|
|
8
|
-
|
|
9
9
|
const posts = await wp.getAllPosts();
|
|
10
10
|
return getStaticPathsForPages(posts, { postsPerPage: config.postsPerPage ?? 5 });
|
|
11
11
|
}
|
|
@@ -27,23 +27,16 @@ const t = {
|
|
|
27
27
|
const base = import.meta.env.BASE_URL;
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
dateLocale={config.locale ?? "en"}
|
|
44
|
-
t={t}
|
|
45
|
-
locale={config.locale ?? "en"}
|
|
46
|
-
layout={config.defaultLayout ?? "magazine"}
|
|
47
|
-
/>
|
|
48
|
-
</body>
|
|
49
|
-
</html>
|
|
30
|
+
__LAYOUT_OPEN__
|
|
31
|
+
<BlogList
|
|
32
|
+
posts={posts}
|
|
33
|
+
currentPage={currentPage}
|
|
34
|
+
totalPages={totalPages}
|
|
35
|
+
basePath={`${base}blog/page/`}
|
|
36
|
+
blogBase={`${base}blog/`}
|
|
37
|
+
dateLocale={config.locale ?? "en"}
|
|
38
|
+
t={t}
|
|
39
|
+
locale={config.locale ?? "en"}
|
|
40
|
+
layout={config.defaultLayout ?? "magazine"}
|
|
41
|
+
/>
|
|
42
|
+
__LAYOUT_CLOSE__
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { BlogPost, Comments, CommentForm } from "astro-blog-kit/components";
|
|
3
3
|
import { createWPClient, getStaticPathsForPosts } from "astro-blog-kit/utils";
|
|
4
4
|
import config from "../../../blog.config";
|
|
5
|
+
__LAYOUT_IMPORT__
|
|
5
6
|
|
|
6
7
|
export async function getStaticPaths() {
|
|
7
8
|
const wp = createWPClient(config.wpUrl);
|
|
@@ -27,15 +28,8 @@ const t = {
|
|
|
27
28
|
};
|
|
28
29
|
---
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
</head>
|
|
36
|
-
<body>
|
|
37
|
-
<BlogPost post={post} t={t} lang={config.locale ?? "en"} />
|
|
38
|
-
<Comments comments={comments} postId={post.id ?? 0} />
|
|
39
|
-
<CommentForm postId={post.id ?? 0} apiRoute="/api/comments" />
|
|
40
|
-
</body>
|
|
41
|
-
</html>
|
|
31
|
+
__LAYOUT_OPEN__
|
|
32
|
+
<BlogPost post={post} t={t} lang={config.locale ?? "en"} />
|
|
33
|
+
<Comments comments={comments} postId={post.id ?? 0} />
|
|
34
|
+
<CommentForm postId={post.id ?? 0} apiRoute="/api/comments" />
|
|
35
|
+
__LAYOUT_CLOSE__
|