In many tech conferences, attendees are invited to rate the talk and/or the speaker from 1 to 5 stars. This type of ratings is interesting but has a few drawbacks.
The discussion started as a twitter thread with this french proposition.
--- | |
layout: null | |
permalink: robots.txt | |
--- | |
# filter pages and documents for the noindex key | |
{% assign noindexPages = site.pages | where: 'sitemap', false %} | |
{% assign noindexDocuments = site.documents | where: 'sitemap', false %} | |
User-agent: * | |
# robotstxt.org - if _config production variable is false robots will be disallowed. | |
{% if site.production != true %} |
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 |
In many tech conferences, attendees are invited to rate the talk and/or the speaker from 1 to 5 stars. This type of ratings is interesting but has a few drawbacks.
The discussion started as a twitter thread with this french proposition.
<!-- image --> | |
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}> | |
{{ with .Get "link"}}<a href="{{.}}">{{ end }} | |
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }} class="lazyload" /> | |
<noscript> | |
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}/> | |
</noscript> | |
{{ if .Get "link"}}</a>{{ end }} | |
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} | |
<figcaption>{{ if isset .Params "title" }} |
The following allows you to easily generate an Algolia index with Hugo consisting of whatever front matter metadata you like.
There are plugins that generate indexes using NPM packages or other tools. The issue is that they don't have any context to your site configuration or Hugo's internals, so they may miss pages or index pages that should not be indexed.
Using Hugo means your index has the full context of your site available when being generated.
To generate the index you create the index's layout at layouts/_default/list.algolia.json
.
I recently had to upgrade my blog, which involved changes such as:
The upgrading process was not trivial, and some parts (e.g. RSS, sitemap, or twitter cards tags) are not immediately visible, so I decided to add unit tests on the generated content.
{{- $.Scratch.Add "index" slice -}} | |
{{$index := where .Site.RegularPages ".Section" "not in" (slice "links" "internal") }} | |
{{- range $index -}} | |
{{ with .Params.images }} | |
{{ $.Scratch.Set "image" (index . 0)}} | |
{{ else }} | |
{{ $.Scratch.Set "image" "/uploads/logo.jpg"}} | |
{{ end }} | |
{{ $image := printf "%s%s" (replace ($.Scratch.Get "image") "/uploads" .Site.Params.image_url) "?fit=crop&h=201&w=358" }} | |
{{- $content_filtered := replaceRE "(?m)(?i)(?s:\\ba\\b|\\band\\b|\\barchival\\b|\\bagain\\b|\\bin\\b|\\bto\\b|\\bis\\b|\\bno\\b|\\bor\\b|\\bthis\\b|\\bwell\\b|\\byes\\b|\\bthe\\b|\\bthere\\b|\\bthese\\b|\\bthen\\b)" "" (delimit .PlainWords " ") -}} |
title | year | layout |
---|---|---|
An example |
2018 |
example.njk |
const puppeteer = require('puppeteer'); | |
const imagemin = require('imagemin'); | |
const imageminPngquant = require('imagemin-pngquant'); | |
// Get the URL and the slug segment from it | |
const url = process.argv[2]; | |
const segments = url.split('/'); | |
const slug = segments[segments.length-2]; | |
(async () => { |
/* eslint-disable */ | |
const fs = require('fs') | |
const sanityClient = require('@sanity/client') | |
const groq = require('groq') | |
const BlocksToMarkdown = require('@sanity/block-content-to-markdown') | |
const config = { projectId: '<YourID>', dataset: '<DatasetName>', useCdn: true } | |
const client = sanityClient(config) | |
const serializers = { |