Last active
June 10, 2023 01:17
-
-
Save daviddarnes/eb956c1a8b57f4249ea57516b06ca89e to your computer and use it in GitHub Desktop.
Revisions
-
daviddarnes revised this gist
Dec 18, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const ghostContentAPI = require("@tryghost/content-api"); const api = new ghostContentAPI({ url: 'https://demo.ghost.io', key: '22444f78447824223cefc48062', version: "v4" }); const template = ` -
daviddarnes revised this gist
Aug 12, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,12 +39,12 @@ gulp.task('ghost', async function() { const { published_at, slug } = post; return new File({ path: `${published_at.slice(0,10)}-${slug}.md`, contents: Buffer.from(templateFunction(post)) }); }); // Gulp specific stream stuff return streamArray(files) .pipe(gulp.dest('./_posts')); }); -
daviddarnes revised this gist
Aug 12, 2019 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ { "name": "ghost-to-jekyll", "version": "1.0.0", "description": "Import Ghost into a Jekyll site", "main": "gulpfile.js", "scripts": { "test": "gulp ghost" }, "author": "David Darnes", "license": "MIT", "dependencies": { "@tryghost/content-api": "^1.2.7", "gulp": "^4.0.2", "handlebars": "^4.1.2", "stream-array": "^1.1.2", "vinyl": "^2.2.0" } } -
daviddarnes revised this gist
Aug 12, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ tags: {{{ html }}} `; const templateFunction = Handlebars.compile(template.trim()); gulp.task('ghost', async function() { const posts = await api.posts @@ -43,8 +43,8 @@ gulp.task('ghost', async function() { contents: Buffer.from(templateFunction(post)) }); }); // Gulp specific stream stuff return streamArray(files) .pipe(gulp.dest('./_posts')); }); -
daviddarnes revised this gist
Aug 12, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const api = new ghostContentAPI({ version: "v2" }); const template = ` --- title: {{ title }} excerpt: {{{ excerpt }}} @@ -23,7 +23,7 @@ tags: {{{ html }}} `; const templateFunction = Handlebars.compile(template); gulp.task('ghost', async function() { const posts = await api.posts -
daviddarnes revised this gist
Aug 12, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ tags: {{{ html }}} `; const templateFunction = Handlebars.compile(markdownTemplate); gulp.task('ghost', async function() { const posts = await api.posts @@ -40,7 +40,7 @@ gulp.task('ghost', async function() { return new File({ path: `${published_at.slice(0,10)}-${slug}.md`, contents: Buffer.from(templateFunction(post)) }); }); -
daviddarnes revised this gist
Aug 12, 2019 . 1 changed file with 25 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ 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({ @@ -11,17 +10,7 @@ const api = new ghostContentAPI({ version: "v2" }); const markdownTemplate = ` --- title: {{ title }} excerpt: {{{ excerpt }}} @@ -32,20 +21,30 @@ tags: {{/each}} --- {{{ html }}} `; const markdownTemplateFn = Handlebars.compile(markdownTemplate); gulp.task('ghost', async function() { const posts = await api.posts .browse({ include: "tags,authors", limit: "all" }) .catch(err => { console.error(err); }); const files = posts.map(post => { const { published_at, slug } = post; return new File({ path: `${published_at.slice(0,10)}-${slug}.md`, contents: Buffer.from(markdownTemplateFn(post)) }); }); // Gulp specific stream stuff return streamArray(files) .pipe(gulp.dest('./_posts')); }); -
daviddarnes revised this gist
Aug 11, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,8 +36,10 @@ tags: return streamArray(posts) .pipe(through.obj(function (post, encoding, callback) { const { published_at, slug } = post; const file = new File({ path: `${published_at.slice(0,10)}-${slug}.md`, contents: new Buffer.from(markdownTemplate.trim()), data: post, }); -
daviddarnes revised this gist
Aug 11, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,8 @@ const through = require('through2'); const ghostContentAPI = require("@tryghost/content-api"); const api = new ghostContentAPI({ url: 'https://demo.ghost.io', key: '22444f78447824223cefc48062', version: "v2" }); -
daviddarnes revised this gist
Aug 8, 2019 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,12 +21,8 @@ gulp.task('ghost', async function() { console.error(err); }); const markdownTemplate = ` --- title: {{ title }} excerpt: {{{ excerpt }}} feature_image: {{ feature_image }} @@ -35,12 +31,19 @@ tags: - {{ this.slug }} {{/each}} --- {{{ html }}} `; return streamArray(posts) .pipe(through.obj(function (post, encoding, callback) { const file = new File({ path: `${post.published_at.slice(0,10)}-${post.slug}.md`, contents: new Buffer.from(markdownTemplate.trim()), data: post, }); this.push(file); callback(); })) .pipe(hb()) .pipe(gulp.dest('./_posts')); }); -
daviddarnes created this gist
Aug 8, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ const File = require('vinyl'); const gulp = require("gulp"); const hb = require('gulp-hb'); const streamArray = require('stream-array'); const through = require('through2'); const ghostContentAPI = require("@tryghost/content-api"); const api = new ghostContentAPI({ url: 'https://gatsby.ghost.io', key: '9cc5c67c358edfdd81455149d0', version: "v2" }); gulp.task('ghost', async function() { const posts = await api.posts .browse({ include: "tags,authors", limit: "all" }) .catch(err => { console.error(err); }); return streamArray(posts) .pipe(through.obj(function (post, encoding, callback) { const file = new File({ path: `${post.published_at.slice(0,10)}-${post.slug}.md`, contents: new Buffer.from( `--- title: {{ title }} excerpt: {{{ excerpt }}} feature_image: {{ feature_image }} tags: {{#each tags}} - {{ this.slug }} {{/each}} --- {{{ html }}}`), data: post, }); this.push(file); callback(); })) .pipe(hb()) .pipe(gulp.dest('./_posts')); });