Skip to content

thurti/blog-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Node.js Markdown Blog

This repo is for documentation purpose only. It is not meant to be used in production. But feel free to use the code anyway...

This is a simple node.js blog backend. The app reads markdown files from a directory, parses the front-matter meta data and returns all as json. It also has a simple HTML fallback for the js-is-evil folks.

Usage

  1. Create .env file
PORT=5678
POSTS="/path/to/markdown/files"
STATIC="/path/to/static/files" //eg. images used in markdown files
ORIGIN="http://localhost:3000" //Access-Control-Allow-Origin header
  1. npm run dev
  2. JSON API
    • http://localhost:3000/api/posts
    • http://localhost:3000/api/posts/[slug]
    • http://localhost:3000/api/posts/tag/[tag]
  3. SSR
    • http://localhost:3000/
    • http://localhost:3000/tag/[tag]
    • http://localhost:3000/articles/[slug]
    • http://localhost:3000/portfolio/[slug]
    • http://localhost:3000/about

Markdown File with Frontmatter

Markdown files should have the following attributes in frontmatter. More attributes can be added.

path/to/markdown/files/example_post.md

---
title: 'My First Blog Post'
slug: 'my-first-post'
tags: ['js', 'css]
created_at: '2019-01-01'
published: true
---

# Hello World!

Development

npm run dev     //run app with ts-node
npm run watch   //run tests with ts-mocha
npm run build   //build typescript to /build
npm start       //run app from /build

About

Node.js backend for my personal blog.

Resources

Stars

Watchers

Forks

Packages

No packages published