Categorygithub.com/mrnickel/StaticSiteGenerator
repositorypackage
0.0.7
Repository: https://github.com/mrnickel/staticsitegenerator.git
Documentation: pkg.go.dev

# README

You probably don't want to use this

This was created by myself as a fun project in order to get my feet wet with Go. If you want a real static site generator I suggest you use Hugo.

Static Site Generator

This project essentially has 2 things that it does

  1. It creates a markdown file that we can add to our github repo. This markdown file will include the following in the header:

    1. Date
    2. Draft
    3. Title
  2. It parses through all of the markdown files creating static html versions of it

Commands

  • StaticSiteGenerator publish "*title of post*"
  • StaticSiteGenerator create "*title of post*"
  • StaticSiteGenerator stats
  • StaticSiteGenerator listdrafts
  • StaticSiteGenerator preview "*title of post*"
  • StaticSiteGenerator regenerate

#Requirements In order to use this VERY basic system you will have to follow a few basic rules:

Folder structure

We assume a very specific folder structure:

  • / Root path to your site
    • /html This is where the generated static HTML files will go
    • /md This is where StaticSiteGenerator create will put the generated markdown files
    • /templates _This is where the template files go.

##Templates The templates are pretty basic and utilize Go's built in template package. All of the placeholders are the Post struct's fields

type Post struct {
	Date           time.Time
	Draft          bool
	Title          string
	MDContent      string
	HTMLContent    string
	Summary        string
	FileNamePrefix string
}

Create Release

Creating a tag in the format vXXX will kick off a github action to create a new release

git tag vXXX
git push origin vXXX

TODO

  • only show the first paragraph on index pages
  • have "preview" start a server session in order to serve up the page
  • Add "stats" function to post. This will tell you # of typos, how long it's been in draft mode and the number of words
  • Add spell checker
  • Add function to verify links are correct
  • Limit index generation to 10 items per page
  • Add pagination
  • Update this readme to be more informative
  • Write basic wiki in order to remind myself how to use it, for the 2-3 blog posts I actually make / year
  • properly figure out packages, so my helper / private functions don't pollute the project
  • become more consistent with naming... i.e. article vs post
  • make constants generic so as to presume the app is installed and not being run via go run
  • document website requirements. i.e. folder structure and template structure
  • post to reddit / hackernews / twitter so as to get feedback
  • create preview function to see what my markdown looks like when in the templates
  • vendoring?
  • RSS feed generation
  • refactor code to be based around post struct
  • put everything under root as outlined in Peter Bourgon's Go: Best Practices for Production Environments
  • create newsite command
  • better check user data from start so as to not panic and quit right off the bat (better error handling)
  • Look into creating a file watcher that will re-generate the HTML upon save of md file when we're in preview mode