Skip to content

Instantly share code, notes, and snippets.

View budparr's full-sized avatar
🎯
Focusing

Bud Parr budparr

🎯
Focusing
View GitHub Profile
@budparr
budparr / Jekyll-pages-organized-in-folder
Created April 17, 2016 13:00
How to make Jekyll Pages more organized
Add this to your config.yml file:
```
include:
- _pages
```
and then, if you want the filename to be your permalink (without the _pages in the url), do this: in config.yml, add this to your defaults:
```
- scope:
path: '_pages'
values:
@budparr
budparr / csplit.txt
Last active September 28, 2018 08:56
Terminal command to split a list of markdown items into separate documents. Given a "slug" value, the file will be named that. You could also change slug to title and create slugs/filenames from the title. You may also want to run your output through a markdown converter, like https://github.com/domchristie/to-markdown
csplit -k -n 3 export.txt '/^@@@/' {'999'}; for i in xx*; do sed -i '' 's/@@@/---/g' $i; done; for i in xx*; do mv $i `egrep -m1 -e 'slug:.*' $i | sed -e s/[^\]\[A-Za-z0-9~.,_{}\(\)\'\-\+]/-/g -e s/slug--//`.md; done

Keybase proof

I hereby claim:

  • I am budparr on github.
  • I am budparr (https://keybase.io/budparr) on keybase.
  • I have a public key whose fingerprint is 9DDE D468 81E7 3D62 C315 1F12 FFD4 EFBD AF91 5796

To claim this, I am signing this object:

@budparr
budparr / jekyll-events.html
Last active July 25, 2016 01:49
Jekyll Events, with limiting posts
{% assign events = "" | split: "|" %}
{% for item in site.posts %}
{% assign current_date = site.time | date: "%Y%m%d" %}
{% assign postdate = item.date | date: "%Y%m%d" %}
{% if postdate > current_date %}
{% assign events = events | push: item %}
{% endif %}
{% endfor %}
@budparr
budparr / test.html
Created November 10, 2016 17:36
Sample code for Jekyll Workshop
<!-- code -->
@budparr
budparr / widow-control.js
Created November 17, 2016 20:47
widow control script
//control widows, ala www.css-tricks.com/preventing-widows-in-post-titles/
$("ID").each(function() {
var wordArray = $(this).text().split(" ");
if (wordArray.length > 1) {
wordArray[wordArray.length-2] += "&nbsp;" + wordArray[wordArray.length-1];
wordArray.pop();
$(this).html(wordArray.join(" "));
}
});
@budparr
budparr / hugo-multiple-where-statmenets.html
Last active June 4, 2024 19:16
multiple where statements Remember that Hugo uses parameters in the range statement from the inside out. Order matters.
{{ range first 3 (where (where .Site.Pages.ByDate.Reverse "Section" "posts") ".Title" "!=" .Title) }}
<!-- latest posts -->
{{ end }}
@budparr
budparr / hugo-repeater.html
Created January 12, 2017 03:12
Hugo repeater using modulo
{{ define "main" }}
{{ $.Scratch.Add "boxClasses" "dt flex center pt0 pb3 pv3-m pv3-ns" }}
{{ $.Scratch.Add "boxCopyClasses" "db dtc-ns v-mid w-100 w-75-ns" }}
{{ $.Scratch.Add "boxImageClasses" "db dtc-ns v-mid-ns w-25" }}
{{ $.Scratch.Add "ImageClasses" "w-100" }}
<main class="cf pa3 pa4-m pa5-l mw9 w-60-l center">
<h2>
{{ .Title }}
</h2>
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{ $.Scratch.Add "path" .Site.BaseURL }}
<ol class="breadcrumbs">
<li><a href="/">home</a></li>
{{ range $index, $element := split $url "/" }}
{{ $.Scratch.Add "path" $element }}
{{ if ne $element "" }}
<li><a href='{{ $.Scratch.Get "path" }}'>{{ . }}</a></li>
{{ $.Scratch.Add "path" "/" }}
{{ end }}
.Site.Pages = All the Pages (note the capital P) in the site.
.Data.Pages: All the Pages for the given Node (sections, taxonomies). This will be a subset of the above for all other nodes than the home page: On that Node I believe these slices are the same.