astro-blog-kit 0.2.3 → 0.2.5

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 CHANGED
@@ -42,9 +42,9 @@ 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"
45
+ hasLayout: () => p.confirm({
46
+ message: "Do you have a Layout component?",
47
+ initialValue: true
48
48
  }),
49
49
  postsPerPage: () => p.text({
50
50
  message: "Posts per page",
@@ -82,23 +82,47 @@ async function main() {
82
82
  }
83
83
  }
84
84
  );
85
- const layoutPath = answers.layoutComponent || "";
85
+ const translations = {
86
+ en: {
87
+ T_TAGLINE: "Our Blog",
88
+ T_TITLE_LINE1: "Latest",
89
+ T_TITLE_LINE2: "Articles",
90
+ T_DESCRIPTION: "Welcome to our blog.",
91
+ T_BTNCTA: "Read more",
92
+ T_BTN_PREV: "Previous",
93
+ T_BTN_NEXT: "Next"
94
+ },
95
+ es: {
96
+ T_TAGLINE: "Nuestro Blog",
97
+ T_TITLE_LINE1: "\xDAltimos",
98
+ T_TITLE_LINE2: "Art\xEDculos",
99
+ T_DESCRIPTION: "Bienvenido a nuestro blog.",
100
+ T_BTNCTA: "Leer m\xE1s",
101
+ T_BTN_PREV: "Anterior",
102
+ T_BTN_NEXT: "Siguiente"
103
+ }
104
+ };
105
+ const locale = answers.locale;
106
+ const t = translations[locale] ?? translations["en"];
107
+ const hasLayout = answers.hasLayout;
86
108
  const replacements = {
87
109
  WP_URL: answers.wpUrl,
88
110
  POSTS_PER_PAGE: answers.postsPerPage,
89
111
  DEFAULT_LAYOUT: answers.defaultLayout,
90
112
  LOCALE: answers.locale,
91
- LAYOUT_IMPORT: layoutPath ? `import Layout from "${layoutPath}";` : "",
92
- LAYOUT_IMPORT_PAGE: layoutPath ? `import Layout from "../${layoutPath}";` : "",
93
- LAYOUT_OPEN: layoutPath ? `<Layout>` : `<html lang={config.locale ?? "en"}>
113
+ LAYOUT_IMPORT: hasLayout ? `import Layout from "../../layouts/Layout.astro";` : "",
114
+ LAYOUT_IMPORT_PAGE: hasLayout ? `import Layout from "../../../layouts/Layout.astro";` : "",
115
+ LAYOUT_IMPORT_SLUG: hasLayout ? `import Layout from "../../layouts/Layout.astro";` : "",
116
+ LAYOUT_OPEN: hasLayout ? `<Layout>` : `<html lang={config.locale ?? "en"}>
94
117
  <head>
95
118
  <meta charset="UTF-8" />
96
119
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
97
120
  <title>Blog</title>
98
121
  </head>
99
122
  <body>`,
100
- LAYOUT_CLOSE: layoutPath ? `</Layout>` : ` </body>
101
- </html>`
123
+ LAYOUT_CLOSE: hasLayout ? `</Layout>` : ` </body>
124
+ </html>`,
125
+ ...t
102
126
  };
103
127
  const cwd = process.cwd();
104
128
  const spinner2 = p.spinner();
package/cli.ts CHANGED
@@ -65,10 +65,10 @@ 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",
68
+ hasLayout: () =>
69
+ p.confirm({
70
+ message: "Do you have a Layout component?",
71
+ initialValue: true,
72
72
  }),
73
73
 
74
74
  postsPerPage: () =>
@@ -117,25 +117,53 @@ async function main() {
117
117
 
118
118
  // ── Replacements ──────────────────────────────────────────
119
119
 
120
- const layoutPath = (answers.layoutComponent as string) || "";
120
+ const translations: Record<string, Record<string, string>> = {
121
+ en: {
122
+ T_TAGLINE: "Our Blog",
123
+ T_TITLE_LINE1: "Latest",
124
+ T_TITLE_LINE2: "Articles",
125
+ T_DESCRIPTION: "Welcome to our blog.",
126
+ T_BTNCTA: "Read more",
127
+ T_BTN_PREV: "Previous",
128
+ T_BTN_NEXT: "Next",
129
+ },
130
+ es: {
131
+ T_TAGLINE: "Nuestro Blog",
132
+ T_TITLE_LINE1: "Últimos",
133
+ T_TITLE_LINE2: "Artículos",
134
+ T_DESCRIPTION: "Bienvenido a nuestro blog.",
135
+ T_BTNCTA: "Leer más",
136
+ T_BTN_PREV: "Anterior",
137
+ T_BTN_NEXT: "Siguiente",
138
+ },
139
+ };
140
+
141
+ const locale = answers.locale as string;
142
+ const t = translations[locale] ?? translations["en"];
143
+
144
+ const hasLayout = answers.hasLayout as boolean;
121
145
 
122
146
  const replacements: Record<string, string> = {
123
147
  WP_URL: answers.wpUrl as string,
124
148
  POSTS_PER_PAGE: answers.postsPerPage as string,
125
149
  DEFAULT_LAYOUT: answers.defaultLayout as string,
126
150
  LOCALE: answers.locale as string,
127
- LAYOUT_IMPORT: layoutPath
128
- ? `import Layout from "${layoutPath}";`
151
+ LAYOUT_IMPORT: hasLayout
152
+ ? `import Layout from "../../layouts/Layout.astro";`
153
+ : "",
154
+ LAYOUT_IMPORT_PAGE: hasLayout
155
+ ? `import Layout from "../../../layouts/Layout.astro";`
129
156
  : "",
130
- LAYOUT_IMPORT_PAGE: layoutPath
131
- ? `import Layout from "../${layoutPath}";`
157
+ LAYOUT_IMPORT_SLUG: hasLayout
158
+ ? `import Layout from "../../layouts/Layout.astro";`
132
159
  : "",
133
- LAYOUT_OPEN: layoutPath
160
+ LAYOUT_OPEN: hasLayout
134
161
  ? `<Layout>`
135
162
  : `<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>`,
136
- LAYOUT_CLOSE: layoutPath
163
+ LAYOUT_CLOSE: hasLayout
137
164
  ? `</Layout>`
138
165
  : ` </body>\n</html>`,
166
+ ...t
139
167
  };
140
168
 
141
169
  // ── Copia archivos ────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-blog-kit",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "A ready-to-use blog system for Astro with WordPress headless support, optional i18n, multiple layouts, and a comment system.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -9,13 +9,13 @@ const { posts, totalPages } = await wp.getPosts({ perPage: config.postsPerPage ?
9
9
 
10
10
  const t = {
11
11
  blog: {
12
- tagline: "Our Blog",
13
- title_line1: "Latest",
14
- title_line2: "Articles",
15
- description: "Welcome to our blog.",
16
- btncta: "Read more",
17
- btn_prev: "Previous",
18
- btn_next: "Next",
12
+ tagline: "__T_TAGLINE__",
13
+ title_line1: "__T_TITLE_LINE1__",
14
+ title_line2: "__T_TITLE_LINE2__",
15
+ description: "__T_DESCRIPTION__",
16
+ btncta: "__T_BTNCTA__",
17
+ btn_prev: "__T_BTN_PREV__",
18
+ btn_next: "__T_BTN_NEXT__",
19
19
  },
20
20
  };
21
21
 
@@ -2,7 +2,7 @@
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
+ __LAYOUT_IMPORT_PAGE__
6
6
 
7
7
  export async function getStaticPaths() {
8
8
  const wp = createWPClient(config.wpUrl);
@@ -14,13 +14,13 @@ const { posts, currentPage, totalPages } = Astro.props;
14
14
 
15
15
  const t = {
16
16
  blog: {
17
- tagline: "Our Blog",
18
- title_line1: "Latest",
19
- title_line2: "Articles",
20
- description: "Welcome to our blog.",
21
- btncta: "Read more",
22
- btn_prev: "Previous",
23
- btn_next: "Next",
17
+ tagline: "__T_TAGLINE__",
18
+ title_line1: "__T_TITLE_LINE1__",
19
+ title_line2: "__T_TITLE_LINE2__",
20
+ description: "__T_DESCRIPTION__",
21
+ btncta: "__T_BTNCTA__",
22
+ btn_prev: "__T_BTN_PREV__",
23
+ btn_next: "__T_BTN_NEXT__",
24
24
  },
25
25
  };
26
26
 
@@ -2,7 +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
+ __LAYOUT_IMPORT_SLUG__
6
6
 
7
7
  export async function getStaticPaths() {
8
8
  const wp = createWPClient(config.wpUrl);
@@ -17,13 +17,13 @@ const comments = post.id ? await wp.getComments(post.id) : [];
17
17
 
18
18
  const t = {
19
19
  blog: {
20
- tagline: "Our Blog",
21
- title_line1: "Latest",
22
- title_line2: "Articles",
23
- description: "Welcome to our blog.",
24
- btncta: "Read more",
25
- btn_prev: "Back to blog",
26
- btn_next: "Next",
20
+ tagline: "__T_TAGLINE__",
21
+ title_line1: "__T_TITLE_LINE1__",
22
+ title_line2: "__T_TITLE_LINE2__",
23
+ description: "__T_DESCRIPTION__",
24
+ btncta: "__T_BTNCTA__",
25
+ btn_prev: "__T_BTN_PREV__",
26
+ btn_next: "__T_BTN_NEXT__",
27
27
  },
28
28
  };
29
29
  ---