◊(Local Yarn Code "Artifact [d7b70e83]")

Artifact d7b70e832e8edf0d63f18128731b17cb6aefaf4fa0f6ce987167a622d87bc1a2:

#lang pollen/mode racket/base

; SPDX-License-Identifier: BlueOak-1.0.0
; This file is licensed under the Blue Oak Model License 1.0.0.

;; Script/template for starting a new article

(require racket/date

(provide main)

(define (normalize str)
  (define alphanum-only
    (regexp-replace* #rx"[^A-Za-z0-9 ]" str ""))
  (string-normalize-spaces (string-downcase alphanum-only) #px"\\s+" "-"))

(define (make-filename basename)
  (build-path (current-directory) articles-folder (string-append basename ".poly.pm")))

(define (comment . strs)
  (format "◊; ~a" (apply string-append strs)))

(define date-string
  (parameterize [(date-display-format 'iso-8601)]
    (date->string (current-date))))

(define (make-template-contents title)
 #lang pollen

 ◊comment{Copyright ◊(substring date-string 0 4) by ◊|default-authorname|. All Rights Reserved.}

 ◊"◊"(define-meta published "◊date-string")
 ◊"◊"(define-meta conceal   "blog,feed")  ; Edit/delete this line when ready to publish
 ◊"◊;"(define-meta series "seriesname")


 Write here!})

(define (main)
  (display "Enter title: ")
  (define title (read-line))
  (cond [(non-empty-string? title)
         (define post-file (make-filename (normalize title)))
         (define post-contents (make-template-contents title))
         (display-to-file post-contents post-file)
         (displayln (format "Saved to ~a" post-file))

         ; the + argument tells vim to place the cursor at the last line of the file.
         (system (format "mvim + ~a" post-file))]))