@lexho111/plainblog 0.2.5 → 0.2.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/Blog.js CHANGED
@@ -113,9 +113,12 @@ export default class Blog {
113
113
  res.end();
114
114
  } else {
115
115
  res.writeHead(401, { "Content-Type": "text/html" });
116
- res.end(`<style>${this.styles}</style><h1>Unauthorized</h1><p>Please enter the password.<form method="POST">
117
- <input type="password" name="password" placeholder="Password" />
118
- <button style="margin: 2px;">Login</button></form>`);
116
+ res.end(`<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>${this.styles}</style></head>
117
+ <body>
118
+ <h1>Unauthorized</h1><p>Please enter the password.<form method="POST">
119
+ <input type="password" name="password" placeholder="Password" />
120
+ <button style="margin: 2px;">Login</button></form>
121
+ </body></html>`);
119
122
  }
120
123
  }
121
124
 
@@ -214,9 +217,12 @@ export default class Blog {
214
217
  if (req.url === "/login") {
215
218
  if (req.method === "GET") {
216
219
  res.writeHead(200, { "Content-Type": "text/html" });
217
- res.end(`<style>${this.styles}</style><h1>Login</h1><form method="POST">
218
- <input type="password" name="password" placeholder="Password" />
219
- <button style="margin: 2px;">Login</button></form>`);
220
+ res.end(`<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>${this.styles}</style></head>
221
+ <body>
222
+ <h1>Login</h1><form method="POST">
223
+ <input type="password" name="password" placeholder="Password" />
224
+ <button style="margin: 2px;">Login</button></form>
225
+ </body></html>`);
220
226
  return;
221
227
  } else if (req.method === "POST") {
222
228
  await this.handleLogin(req, res);
@@ -387,7 +393,7 @@ export default class Blog {
387
393
  articles: this.articles,
388
394
  };
389
395
  const markdown = formatMarkdown(data);
390
- return markdown;
396
+ console.log(markdown);
391
397
  }
392
398
 
393
399
  /** render this blog content to valid html */
package/Formatter.js CHANGED
@@ -21,6 +21,7 @@ export function formatHTML(data, script, style) {
21
21
  <html lang="de">
22
22
  <head>
23
23
  <meta charset="UTF-8">
24
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
24
25
  <title>${data.title}</title>
25
26
  <style>${style}</style>
26
27
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "A tool for creating and serving a minimalist, single-page blog.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/test/blog.test.js CHANGED
@@ -71,11 +71,12 @@ describe("test blog", () => {
71
71
  const consoleSpy = jest.spyOn(console, "log").mockImplementation(() => {});
72
72
 
73
73
  // Act: Call the method we want to test
74
- await myblog.print();
74
+ myblog.print();
75
+ await new Promise((resolve) => setTimeout(resolve, 100));
75
76
 
76
77
  // Assert: Check if console.log was called with the correct strings
77
78
  expect(consoleSpy).toHaveBeenCalled();
78
- const output = consoleSpy.mock.calls[0][0];
79
+ const output = consoleSpy.mock.calls.map((call) => call[0]).join("\n");
79
80
  expect(output).toContain("# My Test Blog");
80
81
  expect(output).toContain("## Article 1");
81
82
  expect(output).toContain("Content 1");