Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Making things to help others make things

David Darnes daviddarnes

👨‍💻
Making things to help others make things
View GitHub Profile
@daviddarnes
daviddarnes / head.html
Last active Jan 20, 2020
Redirect Ghost preview links to your JAMstack site
View head.html
<script type="text/javascript">
if (location.hostname.includes('ghost.io') && !location.href.includes('ghost.io/p/')) {
location.hostname = 'my-jamstack-site.com';
}
</script>
@daviddarnes
daviddarnes / app.js
Created Jan 9, 2020
Mini Node server for triggering 11ty builds
View app.js
const http = require('http');
const process = require('process');
const { exec } = require('child_process');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
console.log('Ghost content updated!');
process.chdir('../eleventy/');
@daviddarnes
daviddarnes / gulpfile.js
Last active Jul 9, 2020
Import your Ghost posts into a Jekyll project using Gulp
View gulpfile.js
const File = require('vinyl');
const gulp = require("gulp");
const Handlebars = require('handlebars');
const streamArray = require('stream-array');
const ghostContentAPI = require("@tryghost/content-api");
const api = new ghostContentAPI({
url: 'https://demo.ghost.io',
key: '22444f78447824223cefc48062',
version: "v2"
@daviddarnes
daviddarnes / index.njk
Created Jun 1, 2019
Eleventy blog from API
View index.njk
<h1>API post list</h1>
<ul>
{% for post in posts %}
<li>
<a href="/posts/{{ post.id }}/">{{ post.title }}</a>
</li>
{% endfor %}
</ul>
View reading-list.md
@daviddarnes
daviddarnes / pluralise.twig
Created Oct 31, 2017
Pluralising with Twig
View pluralise.twig
{% spaceless %}
{% if integer > 1 %}
{{ plural }}
{% else %}
{{ singular }}
{% endif %}
{% endspaceless %}
@daviddarnes
daviddarnes / repeatify.js
Last active Mar 14, 2017
repeatify test
View repeatify.js
function repeatify(count) {
let newString = this;
for (var i = 1; i < count; i++) {
newString += this;
}
return newString;
}
String.prototype.repeatify = repeatify;
@daviddarnes
daviddarnes / file-structure.md
Last active Jun 15, 2016
Jekyll theme file structure
View file-structure.md

root

  • garth-jekyll-theme.gemspec
  • _layouts
    • default.html
    • page.html
    • front.html
    • post.html
  • _includes
    • header.html
    • footer.html
@daviddarnes
daviddarnes / schema-index-new.html
Last active May 19, 2016
Revised Jekyll SEO Tag JSON LD structure
View schema-index-new.html
<!-- Proposed Index json output -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name": "Dave’s Blog",
"headline": "Dave’s Blog",
"image": "https://www.gravatar.com/avatar/6c0377abcf4da91cdd35dea4554b2a4c?s=600",
"description": "Articles, tutorials and other ramblings",
"publisher": {
You can’t perform that action at this time.