@lexho111/plainblog
v0.8.5
Published
A tool for creating and serving a minimalist, single-page blog.
Readme
Plainblog
Plainblog is a simple blog generator to help you to set up and to maintain a minimalistic single-page blog. You can add new articles directly in the browser. Your data will be stored by default in two file called bloginfo.json and articles.txt.
Installation
npm install @lexho111/plainblogQuick Start
import Blog from "@lexho111/plainblog";
const blog = new Blog();
blog.title = "My Blog";
blog.style = "body { font-family: Arial, sans-serif; } h1 { color: #333; }";
blog.password = "mypassword"
await blog.init();
await blog.startServer();Now you can open your blog in your webbrowser on http://localhost:8080. Login via the login link in the navbar to begin with adding new articles, the password is 'admin'.
or with the BlogBuilder
import { BlogBuilder } from "@lexho111/plainblog";
const blog = new BlogBuilder()
.withTitle("Mein Blog")
.withStyle("body { font-family: Arial, sans-serif; } h1 { color: #333; }")
.withPassword("mypassword")
.build();
await blog.init();
await blog.startServer({ httpPort: 38080, httpsPort: 38443 });More Features
add a header photo
To add a headerphoto to your blog simply name it "headerphoto.jpg" and put it in the public folder.
change view engine
You can put your own angular theme in the public folder.
const blog = new BlogBuilder()
...
.withFrontend("angular")
.build();set a Database Adapter
connect to a sqlite database
import { SqliteAdapter } from "@lexho111/plainblog";
const blog = new Blog();
const sqliteAdapter = new SqliteAdapter({
dbname: "blog",
});
blog.setDatabaseAdapter(sqliteAdapter);
await blog.init();
await blog.startServer();connect to a postgres database
import { PostgresAdapter } from "@lexho111/plainblog";
const blog = new Blog();
const postgresAdapter = new PostgresAdapter({
dbname: "blog",
username: "user",
password: "password",
host: "localhost",
});
blog.setDatabaseAdapter(postgresAdapter);
await blog.init();
await blog.startServer();use different ports
import Blog from "@lexho111/plainblog";
const blog = new Blog();
blog.title = "My Blog";
await blog.init();
await blog.startServer({
httpPort: 38080,
httpsPort: 38443,
});set an API to fetch data from an external database
import Blog from "@lexho111/plainblog";
const blog = new Blog();
blog.setAPI("http://example.com:5432/blog")
blog.setStyle("body { font-family: Arial, sans-serif; } h1 { color: #333; }");
await blog.init(); // load data from database
await blog.startServer();The API should respond to GET-Requests (http://example.com:5432/blog) with json like this:
{
"title": "My Remote Blog",
"articles": [
{
"title": "Welcome to the API Server",
"content": "This content is served from a separate API server.",
"createdAt": "2026-01-12T11:21:55.561Z"
}
]
}Post requests should look like:
curl -X POST http://example.com:5432/blog -H "Content-Type: application/json" -d "{\"title\": \"My new Article.\", \"content\": \"This is the content.\"}"provide custom style sheets
const blog = new Blog();
blog.title = "My Blog";
blog.style = "body { font-family: Arial, sans-serif; } h1 { color: #333; }";
blog.password = "mypassword";
blog.stylesheetPath = "path/to/my/styles.css";
await blog.startServer();use sass compiled stylesheets
import * as sass from "sass";
import fs from "node:fs";
const compiled = sass.compile( "stylesheets/styles.scss");
fs.writeFile("stylesheets_compiled/styles.css", compiled.css, (err) => {
if (err) console.error(err);
});
const blog = new Blog();
blog.stylesheetPath = "stylesheets_compiled/styles.css";
blog.title = "My Blog";
await blog.init();
await blog.startServer();print your blog articles in markdown
blog.print()