hugo-preview-server

command module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: MIT Imports: 18 Imported by: 0

README

Hugo Preview Server

This is in an early stage: It has only been tested with a single demo site and misses some features.

Summary

A piece of glue code that runs Hugo for serving previews for CMS systems.

It uses a git client to get access to assets/layouts of the site and compiles pages based on content passed in via HTTP.

DEMO

There is a demo setup at: https://hugo-preview-server.netlify.com/demo/admin/

Log in via GitHub and select any entry from the "Posts" collection to see it in action.

Features

  • Uses GitHub as a virtual filesystem to get layouts
  • Renders pages on-demand, taking path and data via POST
  • Supports partial re-renders (just like hugo server)
  • Supports extended mode

Roadmap

  • Build & package a solid integration for NetlifyCMS
  • Support custom source branches (only default right now)
  • Provide tooling for easy usage (e.g. npx hugo-preview-server setup:function ./functions)
  • Run as a standalone http server process (for use in docker)

Usage

There is a binary available that can be deployed to AWS Lambda or any compatible platforms like Netlify Functions.

Download in CI

Use this command in your build to get the latest release:

curl -L -s https://github.com/mraerino/hugo-preview-server/releases/latest/download/preview-lambda -o <destination>

# Example for Netlify Functions
mkdir -p functions
curl -L -s https://github.com/mraerino/hugo-preview-server/releases/latest/download/preview-lambda -o functions/preview

See this Netlify.toml for an example. In the future there will be tooling that will make this even easier.

Configuration

The functions needs the following environment variables:

HUGO_PREVIEW_GITHUB_REPO=owner/repo # path to the repo where your hugo site is located
HUGO_PREVIEW_GITHUB_TOKEN=<token>   # a personal or oauth token that allows read access to the repo
HUGO_PREVIEW_BASE=<path>            # optional, use when your hugo site is not based in the repo root

Run locally

Requirements:

While developing, use the make commands to get a binary:

  • make build - if you are on linux
  • make in-docker - any other system

License

See LICENSE file

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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