blog

package module
v0.0.0-...-b64c017 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2014 License: MIT Imports: 11 Imported by: 0

README

blog

A simple blog written in Go and based on Gorilla mux and blackfriday.

Rationale

There are plenty of blog frameworks out there, both static and dynamic, which offer a lot of great functionality and robustness out of the box. This is not necessarily one of those frameworks.

This package is for those who want a simple blog to drop into an existing Go-based website. Adding a page is as simple as writting a Golang HTML template, dropping semantically-named blog posts written in markdown into a directory, and adding a new route to your mux.

Usage

Installation:

$ go get github.com/scott-linder/blog

In your template:

{{range $post := .Posts}}
<article>
<a href="{{$post.Permalink}}><h1>{{$post.Name}}</h1></a>
{{$post.Body}}
</article>
{{else}}
<p>No posts.</p>
{{end}}

In your source:

r := mux.NewRouter()
sb := r.PathPrefix("/blog").Subrouter()
blog.NewBlog("name", sb, "path/to/template.tpl", "path/to/posts/", pageSize)

Documentation

Overview

Package blog is a simple blog based on Gorilla mux and blackfriday markdown.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blog

type Blog struct {
	// contains filtered or unexported fields
}

Blog is a blog site Handler..

func NewBlog

func NewBlog(name string, router *mux.Router, tplPath, postDir string,
	pageSize int) (blog *Blog)

NewBlog returns a new Blog instance.

func NewBlogSimple

func NewBlogSimple(name string, router *mux.Router) *Blog

NewBlogSimple is a shorthand for NewBlog with default arguments.

func (Blog) ServeHTTP

func (self Blog) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL