all repos — vite @ a52a946d392ee831216565bbfb67acf5d9f20ae3

a fast (this time, actually) and minimal static site generator

new.go (view raw)

 1package main
 2
 3import (
 4	"fmt"
 5	"io/ioutil"
 6	"os"
 7	"path/filepath"
 8	"strings"
 9	"time"
10)
11
12func viteNew(path string) {
13	_, file := filepath.Split(path)
14	url := strings.TrimSuffix(file, filepath.Ext(file))
15
16	content := fmt.Sprintf(`---
17template:
18url: %s
19title:
20subtitle:
21date: %s
22---`, url, time.Now().Format("2006-01-02"))
23
24	_, err := os.Create(path)
25	if err != nil {
26		printErr(err)
27		return
28	}
29	ioutil.WriteFile(path, []byte(content), 0644)
30	printMsg("created:", path)
31}