Blog CLI and static blog project-starter in Deno.
๐ก For a simple tutorial, check out the Getting Started document.
Make sure that you have installed Deno.
Then, install deno-blog-starter
by executing the following command:
deno install --unstable --allow-read --allow-write --allow-net https://deno.land/x/dbs/mod.ts
- Required Permissions:
--allow-read
: The program needs to read your markdown files.--allow-write
: The program needs to generate new files.--allow-net
: The program needs this permission to preview the site in the browser.
Create Blog Post โจ
Each of your blog posts are represented by a markdown file (file with the .md
extension).
Your blog posts can have the following frontmatter associated with them:
---
title: Your Title Here
date: Date
description: Your description here.
published: false # Change to true to include this blog-post.
---
To create a new blog post, run the following command.
dbs --new-post -t "Your Title" -d "Your description."
๐ก You can pass your title and description as well, but they are not required.
The rest of the contents of the blog-post file are written in Markdown.
Or run as an individual script.
deno run --unstable --allow-write --allow-read scripts/new_post.ts -t "Your Title" -d "Your description."
.
Or run via the API.
import { newPost } from "https://deno.land/x/dbs/mod.ts";
const title = "Your Title",
description = "Your description.";
await newPost(title, description);
Generate Blog ๐งโโ๏ธ
To generate the files for your static blog, run the following command:
dbs --build -s "chosen_stylesheet"
You can pass the name of your chosen stylesheet. You may choose between
air
,modest
,retro
, orsplendor
. Themodest
stylesheet is chosen by default. Or you may create a custom stylesheet.
Or run as an individual script.
deno run --unstable --allow-read --allow-write scripts/build.ts -s YOUR_STYLE_TITLE
Or run via the API.
import { build } from "https://deno.land/x/dbs/mod.ts";
const stylesheetTitle = "modest"; // Replace `modest` with your chosen stylesheet's title.
await build(stylesheetTitle);
Preview Blog ๐ก
To preview your blog on your machine, run the following command:
dbs --serve
๐ก Visit http://localhost:8000/ to preview your blog.
๐ก To see your latest changes, remember to re-generate the site.
Or run as an individual script.
deno run --allow-read --allow-net --unstable scripts/serve.ts
Or run via the API.
import { serve } from "https://deno.land/x/dbs/mod.ts";
await serve();
Add Custom Stylesheet ๐
This operation currently only works when you are using this project as a template.
To add a custom stylesheet, run the following command:
dbs --new-style -t "YOUR_STYLE_TITLE"
๐ก You may pass the title of your custom stylesheet as well.
๐ก To integrate your custom stylesheet, update the
styles/YOUR_STYLE_TITLE.ts
file.
Or run as an individual script.
deno run --unstable --allow-read --allow-write scripts/new_style.ts -t "YOUR_STYLE_TITLE"
Or run via the API.
import { newStyle } from "https://deno.land/x/dbs/mod.ts";
const title = "new_stylesheet_title";
await newStyle(undefined, title);
This project is...
- A template/starter repository on GitHub.
- A TypeScript module on
deno.land/x
. - And a CLI (command-line interface).
Final thoughts: This project is not limited to blogging; any directory of loosely organized markdown files will work seamlessly with the
deno-blog-starter
project (such as documentation).
Created with ๐ by EthanThatOneKid