@lexho111/plainblog
v0.2.5
Published
A tool for creating and serving a minimalist, single-page blog.
Downloads
1,654
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.
Installation
npm install @lexho111/plainblogQuick Start
import Blog from "@lexho111/plainblog";
const blog = new Blog();
blog.setTitle("My Blog");
blog.setStyle("body { font-family: Arial, sans-serif; } h1 { color: #333; }");
blog.startServer(8080);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'.
More Features
SQLite is the default database. But you can use PostgreSQL instead.
run api server with postgres database
import Blog from "@lexho111/plainblog";
const blog = new Blog();
blog.database.type = "postgres";
blog.database.username = "user";
blog.database.password = "password";
blog.database.host = "localhost";
blog.setStyle("body { font-family: Arial, sans-serif; } h1 { color: #333; }");
await blog.init(); // load data from database
blog.startServer(8080);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
blog.startServer(8080);save data to file
import Blog from "@lexho111/plainblog";
import { Article } from "@lexho111/plainblog";
const blog = new Blog();
blog.setStyle("body { font-family: Arial, sans-serif; } h1 { color: #333; }");
const article = new Article("hello", "hello world!");
blog.addArticle(article);
blog.save("myblog.json");
// load data from 'myblog.json'
await blog.load("myblog.json");print your blog articles in markdown
blog.print()