This file contains 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 characters
const generateAssetsList = (posts, baseUrl, simpleLog = console.log) => new Promise(async resolve =>{ | |
const apiURL = `${baseUrl.replace(/\/$/, '')}/wp-json/wp/v2/media` | |
simpleLog('Reducing posts to asset numbers') | |
let infosFetched = 0 | |
// First add the featured_media images and get ther URLs. | |
const featuredAssets = await Promise.all(posts.reduce((all, post) => { | |
if (!post.featured_media) return all | |
return all.concat([{ | |
mediaNumber: post.featured_media, |
This file contains 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 characters
const getCategories = (posts, baseUrl, simpleLog = console.log) => new Promise(async resolve => { | |
const apiURL = `${baseUrl.replace(/\/$/, '')}/wp-json/wp/v2/categories` | |
// First reduce posts to an array of category numbers. | |
simpleLog('Reducing posts to category numbers') | |
const categories = await Promise.all(posts.reduce((all, post) => { | |
if(!post.category) return all | |
if(all.indexOf(post.category) > -1) return all | |
return all.concat([post.category]) | |
}, []) | |
.map(async categoryNumber => { |
This file contains 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 characters
const transformPosts = posts => posts.map(post => { | |
delete post._links | |
delete post.guid | |
delete post.excerpt | |
delete post.author | |
delete post.comment_status | |
delete post.ping_status | |
delete post.template | |
delete post.format | |
delete post.meta |
This file contains 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 characters
const exportBlogposts = (apiUrl, log) => new Promise(resolve => { | |
const exportPageOfPosts = (apiUrl, page = 1, allPosts = []) => { | |
log(`Getting posts for page ${page}`) | |
const url = `${apiUrl}?page=${page}` | |
https.get(url, (res) => { | |
// When we get a 404 back we went one page over those with posts. | |
// So we are done now. | |
if(res.statusCode === 400) { | |
return resolve(allPosts) | |
} |
This file contains 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 characters
[{ | |
link: 'link to wordpress iage.jpg', | |
description: 'describe the image', | |
title: 'and title it', | |
postId: 'because linking back is nice' | |
}, ...] |
This file contains 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 characters
#!/usr/bin/env node | |
/* eslint-disable */ | |
/** | |
* Replace the locale in an exported space. | |
* | |
* Usage: | |
* node changeSpaceLocale.js -l es-ES < space.json > translated.json | |
* | |
* The above will translate the space to Spanish (currently the only supported | |
* language to translate to). |
This file contains 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 characters
#!/usr/bin/env node | |
/** | |
* Replace the locale in an exported space. | |
* | |
* Usage: | |
* node changeSpaceLocale.js -l es-ES < space.json > translated.json | |
* | |
* The above will translate the space to Spanish (currently the only supported | |
* language to translate to). | |
*/ |
This file contains 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 characters
git log --all --color --graph --pretty=format:'%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
git config --global alias.lg "log --all --color --graph --pretty=format:'%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
This file contains 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 characters
const numbers = [1, 2, 3, 4] | |
const list = html` | |
<ul> | |
${numbers.map(number => `<li>${number}</li>`)} | |
</ul>` | |
/* | |
At this point we have: | |
<ul> |
This file contains 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 characters
# FTP deploy Hexo based site using Travis-ci.org | |
# https://gist.github.com/HoverBaum/524528aec1032b29669fe9cc82dba066 | |
# | |
# 1. Copy this file to the root of your repository, then rename it to '.travis.yml' | |
# 2. Replace 'YOUR NAME' and 'YOUR EMAIL' | |
# 3. Create "Environment Variables" in travis. Make sure to not show them in the output. | |
# - FTP_USER: The username for FTP transfer. | |
# - FTP_PASSWORD: Password for the user. | |
# 4. Replace "DOMAIN.TLD" with your FTP domain and maybe the path where to put things. | |
# |