2022-10-21

Last night I was reading the goliki source, and was reminded of Gulp. Gulp implements a piping pattern for file transformations. It reads file, pipes buffer of file through various transformations and writes file.

Refactoring goliki means functions that accept and return a page, or an array of pages.

// reads markdown pages stating at current for
Pages := readPages(".")

for _, page := range pages {
  // adds gif info for latest commit involving file
  // then render markdown into partial html
  addCommit(page)
  renderMarkdown(page) 
}

// collects metadata on entire site,
// and add this data into each page
  reduceSite(pages)

for _, page := range pages {
  // render html template with markdown and metadata
  // then write page
  renderHTML(page)
  writePage(page)
}

If I’m passing in a reference to my page and mutating that page, then I don’t really have to return it. That only makes sense with a pure function.

This is one pipeline. Ideally I can create another pipeline for any type of file, like images. I don’t want to process them in the usual sense, but instead read metadata from them to store in Site variable.

Re: images: if I’m going to put them in git then it’s best if I do so post-process. I don’t want raw images that need to be processed to be part of my build chain.

It technically doesn’t matter where I store the images, because file readers will find them, and any references to them must be working relative links. I thought to put them in same folder as markdown, but then the image files will be “in the way” when I’m editing markdown.

I do want to rename images so that the date is encoded, much like the markdown. An index page for all the images will be generated. Oh, they really should go in their own folder, this way I can add README custom index. Wait, does this mean I should generate thumbnails? That’s a classic job.

I also have to come up with a CSS solution. I want to avoid generation and I can manage a static CSS file just fine, but I need to understand a few possibilities: can goldmark add class attributes? Can extensions do this? Can I use a default theme off-shelf, or convert one?

With vanilla CSS, I know I can scope markdown content to a parent tag with class, e.g. <article class="markdown">. This way it doesn’t interfere with anything else from template.

Other than some GA code, there is no JavaScript and I think I want to keep it that way. JavaScript build chains have been tiresome and that’s not the point here. I’d rather make some pretty pages.

If I want to If I want to make a watch file command that runs build on change, then I can use fsnotify.

do Apple-K, Apple-I to show “Definition Preview” of current word. It is the hover box with all the type info.