-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from GemCopeland/eleventy
Eleventy
- Loading branch information
Showing
51 changed files
with
1,745 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,108 @@ | ||
module.exports = function(eleventyConfig) { | ||
const { DateTime } = require("luxon"); | ||
const CleanCSS = require("clean-css"); | ||
const UglifyJS = require("uglify-es"); | ||
|
||
const now = new Date(); | ||
|
||
module.exports = eleventyConfig => { | ||
eleventyConfig.setBrowserSyncConfig({ | ||
notify: true | ||
}); | ||
|
||
// Add profile collection so that we can access this outside of homepage | ||
// TODO Surely there is a better way to do this? Possible to create a data file that pulls from home.md? | ||
eleventyConfig.addCollection("profile", collection => { | ||
return collection.getAll().filter(item => { | ||
return item.data.section == "home"; | ||
}); | ||
}); | ||
|
||
// Minify CSS | ||
eleventyConfig.addFilter("cssmin", code => { | ||
return new CleanCSS({}).minify(code).styles; | ||
}); | ||
|
||
// Minify JS | ||
eleventyConfig.addFilter("jsmin", code => { | ||
let minified = UglifyJS.minify(code); | ||
if (minified.error) { | ||
console.log("UglifyJS error: ", minified.error); | ||
return code; | ||
} | ||
return minified.code; | ||
}); | ||
|
||
// Date formatting | ||
eleventyConfig.addFilter("machineDate", dateObj => { | ||
return DateTime.fromJSDate(dateObj).toFormat("yyyy-MM-dd"); | ||
}); | ||
eleventyConfig.addFilter("readableDate", dateObj => { | ||
return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy"); | ||
}); | ||
eleventyConfig.addFilter("activityDate", dateObj => { | ||
return DateTime.fromJSDate(dateObj).toFormat("MM.yyyy"); | ||
}); | ||
eleventyConfig.addFilter("activityYear", dateObj => { | ||
return DateTime.fromJSDate(dateObj).toFormat("yyyy"); | ||
}); | ||
|
||
// Create Posts collection | ||
eleventyConfig.addCollection("posts", collection => { | ||
const livePosts = p => p.date <= now; | ||
return collection | ||
.getFilteredByGlob("./src/posts/*.md") | ||
.filter(livePosts) | ||
.reverse(); | ||
}); | ||
|
||
// Create activityCurrent collection | ||
eleventyConfig.addCollection("activityCurrent", collection => { | ||
return collection | ||
.getFilteredByGlob("./src/activity/*.md") | ||
.filter(item => { | ||
return item.data.dateEnd >= now; | ||
}) | ||
.reverse(); | ||
}); | ||
|
||
// Create activityPast collection | ||
eleventyConfig.addCollection("activityPast", collection => { | ||
return collection | ||
.getFilteredByGlob("./src/activity/*.md") | ||
.filter(item => { | ||
return item.data.dateEnd < now; | ||
}) | ||
.reverse(); | ||
}); | ||
|
||
// Markdown | ||
let markdownIt = require("markdown-it"); | ||
let options = { | ||
html: true, | ||
breaks: true, | ||
linkify: true | ||
}; | ||
eleventyConfig.addNunjucksFilter("markdownify", markdownString => | ||
markdownIt(options).render(markdownString) | ||
); | ||
|
||
// Copy the fonts | ||
eleventyConfig.addPassthroughCopy({ "src/_includes/assets/fonts": "fonts" }); | ||
|
||
return { | ||
templateFormats: ["md", "njk", "html", "liquid", "woff", "woff2"], | ||
|
||
pathPrefix: "/", | ||
|
||
markdownTemplateEngine: "liquid", | ||
htmlTemplateEngine: "njk", | ||
dataTemplateEngine: "njk", | ||
// passthroughFileCopy: true, | ||
dir: { | ||
input: "src/.", | ||
includes: "_includes", | ||
data: "_data", | ||
output: "_dist" | ||
} | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
README.md | ||
**/_drafts/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
_site/ | ||
|
||
.DS_Store | ||
_dist/ | ||
node_modules/ |
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
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,32 @@ | |
"description": "This is a simple website for publishing a CV, research and writing. It will be used for [gemmacope.land](gemmacope.land).", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "npx eleventy", | ||
"watch": "npx eleventy --watch", | ||
"debug": "DEBUG=* npx eleventy" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/GemCopeland/personal-website.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"author": { | ||
"name": "Piper Haywood", | ||
"email": "[email protected]", | ||
"url": "https://piperhaywood.com/" | ||
}, | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/GemCopeland/personal-website/issues" | ||
}, | ||
"homepage": "https://github.com/GemCopeland/personal-website#readme", | ||
"devDependencies": { | ||
"@11ty/eleventy": "^0.9.0" | ||
"@11ty/eleventy": "^0.9.0", | ||
"are.na": "^0.1.1", | ||
"luxon": "^1.17.2" | ||
}, | ||
"dependencies": { | ||
"clean-css": "^4.2.1", | ||
"uglify-es": "^3.3.9" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: 404 | ||
layout: layouts/page.njk | ||
permalink: /404.html | ||
--- | ||
|
||
Uh oh, the resource you requested isn’t here. Sorry. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// TODO Make this an environment variable | ||
// https://www.11ty.io/docs/data-js/#example%3A-exposing-environment-variables | ||
const arenaChannelId = 479545; | ||
|
||
// Required package | ||
const Arena = require("are.na"); | ||
|
||
const getChannelImages = async arena => { | ||
return arena | ||
.channel(channel.id) | ||
.contents({ page: 1, per: 10 }) // NOTE We’re manually getting the contents because channel.contents sometimes returns null | ||
.then(contents => { | ||
// Get images within channel contents | ||
return contents | ||
.filter(b => b.image) | ||
.map(b => { | ||
return b.image.thumb.url; | ||
}); | ||
}); | ||
}; | ||
|
||
const getArenaChannels = async channelId => { | ||
// Set up the Arena instance | ||
const arena = new Arena(); | ||
// Get the channel | ||
let rootChannel = arena.channel(channelId); | ||
// Set up base URL | ||
let url = "https://are.na/"; | ||
|
||
// Get the channels | ||
let channels = rootChannel | ||
.get() | ||
.then(async channel => { | ||
// Add the user to the base URL | ||
url = url + channel.user.slug + "/"; | ||
|
||
// Create a new array of channel contents | ||
let reducedChannels = await Promise.all( | ||
channel.contents | ||
.filter(block => block.base_class == "Channel") | ||
.map(async channel => { | ||
// Set up the new channel object, somewhat reduced from the default | ||
let newChannel = { | ||
title: channel.title, | ||
description: channel.metadata | ||
? channel.metadata.description | ||
: null, | ||
images: null, | ||
count: channel.length, | ||
url: url + channel.slug | ||
}; | ||
// Add some further content to the channel via its child blocks | ||
newChannel = await arena | ||
.channel(channel.id) | ||
.contents() // NOTE We’re manually getting the contents because channel.contents sometimes returns null | ||
.then(contents => { | ||
// Get images within channel contents | ||
newChannel.images = contents | ||
.filter(b => b.image) | ||
.map(b => { | ||
return b.image.thumb.url; | ||
}) | ||
.reverse() | ||
.slice(0, 10); | ||
|
||
// Get a description from the text blocks if necessary | ||
if (newChannel.description == null) { | ||
let text = contents | ||
.filter(b => { | ||
return b.class == "Text"; | ||
}) | ||
.map(b => { | ||
return b.content; | ||
}) | ||
.join(" ") | ||
.slice(0, 140); | ||
newChannel.description = text ? text + "…" : null; | ||
} | ||
// Return the channel with the additional image and description content | ||
return newChannel; | ||
}); | ||
|
||
// Return the formatted channel object | ||
return newChannel; | ||
}) | ||
); | ||
return reducedChannels.reverse(); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
return null; | ||
}); | ||
return await channels; | ||
}; | ||
|
||
module.exports = getArenaChannels(arenaChannelId); |
Oops, something went wrong.