Posts for: #Info

Hugo Template Render Hooks

This was a tough nut to crack. I’m totally new to Go Html Templates and Go itself, and I’ve never really used anything outside of Jekyll. It took me a minute, but I wound up coming up with this:

{{ $image := (resources.Get .Destination) }}
{{ with $image }}
    {{ if eq $image.MediaType.SubType "svg" }}
        <a data-fancybox="image" href="{{ $image.RelPermalink }}" data-caption="{{ with $.Title }}{{ . }}{{ end }}">
            <img src="{{ $image.RelPermalink }}" {{ with $.Text }} alt="{{ . }}" {{ end }} {{ with $.Title}} title="{{ . }}"{{ end }} />
        </a>
    {{ else }}
        {{ $resize := .Fill "200x165 webp q80" }}
        <a data-fancybox="image" href="{{ $image.RelPermalink }}" data-caption="{{ with $.Title }}{{ . }}{{ end }}">
            <img src="{{ $resize.RelPermalink }}" {{ with $.Text }} alt="{{ . }}" {{ end }} {{ with $.Title}} title="{{ . }}"{{ end }} />
        </a>
    {{ end }}
{{ end }}

Apparently I have a *.svg file on my blog somewhere, because that was a thing I had to catch right away for this to work. So I had to move all my images out of static and into assets for it to work, first of all. Then I had to figure out how to query a parent context, so I could fill in Text and Title with the images. That’s what the $ is in $.Text. It’s the parent context outside of $image.

[]

Fancybox and Hugo Even

My theme apparently wraps every ![Image](source) in another set of <a href=""></a> tags that point to the source for the image. If you’re trying to generate galleries with a shortcode using fancyboxes, this default behavior is going to bite you in the ass. I forced the behavior to what I want/expect by copying assets/js/even.js and assets/js/main.js from themes/even into my blog root assets/js/. Then I hacked out the fancyboxes references in both files and regenerated. Boom, galleries work, and I didn’t lose anything of value in any previous posts. It’s a win/win for my specific situation.

[]

Lmfao

BEHOLD, FUCKING MEMES.

God damn, this thing is really flexible. Just added a layouts/shortcodes/gallery.html and slapped a little Go Html Template and some lightbox.js and whatever, and bing-o bang-o boom; motherfucker is an autogallery. BOOYAH, BITCH.

Cool as fuck.

Of course there’s a little more to it than that. Gotta do some page bundling as well, which is easy enough. Just run your hugo new post/2022-01-01-Title/index.md and dump your images into content/post/2022-01-01-Title/img.

[]

Pinning Posts in Hugo

Alright, in this post I’m going to show you how to pin posts in Hugo. But before you keep reading, I request you review the template you’re using and ensure it’s going to allow you to pin posts in the first place.

The thing you’re looking for is the index declaration in your index.html.

Example:

{{- define "content" -}}
  <section id="posts" class="posts">
    {{/* (index .Site.Paginate) */}}
    {{- $paginator := .Paginate (where (where .Site.RegularPages "Type" "post") ".Params.hiddenfromhomepage" "!=" true) }}
    {{- range $paginator.Pages -}}
      {{ .Render "summary" }}
    {{ end -}}
  </section>

For instance, in the above snipped, line number four is where you can find the $paginator that will tell you whether you’ll be able to pin posts. If you see mine, you’re good. Most are probably going to do this. If you see anything with “sortby” then you’re probably fucked, because your template is probably forcing your shit to sort by date, rather than just paginate as Hugo does by default.

[]

Raspberry Pi Watchdog Timer

Earlier today I experienced an amount of panic that I think most nerds can relate to. I tried to sync my git project and I got “no route to host” in response. GASP. There are so many things that can go wrong, especially when you’re forcing all the heavy lifting on a tiny little raspberry pi. The thing has been a brute every since I got it, though, chugging away with nary a care. It truly has been a workhorse for the specs and size.

[]

My .vimrc

These are the contents of my ~/.vimrc file.

call plug#begin('~/.vim/plugged')

Plug 'scrooloose/nerdtree'
Plug 'sukima/xmledit'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
Plug 'plasticboy/vim-markdown'

call plug#end()

set tabstop=4
set laststatus=2
set selection=inclusive
color desert
set gfn=Essential_PragmataPro:h11
syntax on
set nowrap
set noshowmode
let g:airline_powerline_fonts = 1
let g:airline_theme = 'deus'
let g:airline#extensions#tabline#enabled = 1
set backspace=2
set backspace=indent,eol,start
set nu
autocmd Filetype markdown setlocal spell

set linebreak
set textwidth=0
set wrapmargin=0
set enc=utf-8
set fileencoding=utf-8
map <F9> :execute '!pdflatex ' . shellescape(expand('%')) . ' && start "" ' . shellescape(expand('%:r') . '.pdf')<CR>

PragmataPro Essential font, purchased LEGALLY from that Schiavi guy. Directly from him, as a matter of fact. Would be great if he made the entire font $30 instead of just the “Essential” slimmed down version, but whatever. Iosevka is coming for him.

[]

Irssi Formatting Rebind

I’ve been using irssi a lot lately to mitigate the sheer volume of networks and channels I dick around in on IRC at any given moment, and using TheLounge is great and all, but I’m feeding node.js about 3GB just to keep it running. I’ve noticed that irssi barely breaches 130MB of RAM when left to idle. When you combine irssi with the really neat tricks like 100 windows in irssi, you can have an extremely RAM-efficient setup that’s capable of quick navigation and split-window juggling.

[]

Installing a *.Msixbundle File

This is a pain in the ass. My user profile is prevented from accessing the “Windows Store” by my administrator, because they’re dumb I guess. I dunno. It’s really not a clever move if you think about it, because you’re ensuring that people source their software from places other than “vetted distribution sites” such as Windows Store. But, whatever. This is the workaround. All you’re required to do is open powershell and execute the command Add-AppxPackage file.msixbundle. That’s pretty much it. You may want to do so as administrator, that way the bundle you install is available to everyone who uses the computer, but I’m sure it doesn’t matter either way.

[]