basic eleventy setup

This commit is contained in:
Max Böck 2019-04-13 16:39:52 +02:00
parent 095a4cfd74
commit 7b3d56d9f0
11 changed files with 60 additions and 32 deletions

View file

@ -2,32 +2,34 @@ const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
const htmlMinifier = require('html-minifier')
module.exports = function(config) {
config.addPlugin(syntaxHighlight)
config.addPlugin(syntaxHighlight)
config.addLayoutAlias('base', 'base.njk')
config.addLayoutAlias('base', 'base.njk')
config.addTransform('htmlmin', function(content, outputPath) {
if (outputPath.endsWith('.html')) {
return htmlMinifier.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
})
config.addPassthroughCopy('src/assets/images')
config.addTransform('htmlmin', function(content, outputPath) {
if (outputPath.endsWith('.html')) {
return htmlMinifier.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true
})
}
return content
})
return {
dir: {
input: 'src',
output: 'dist',
includes: 'includes',
layouts: 'layouts',
data: 'data'
},
templateFormats: ['njk', 'md'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
passthroughFileCopy: true
}
return content
})
return {
dir: {
input: 'src',
output: 'dist',
includes: 'includes',
layouts: 'layouts',
data: 'data'
},
templateFormats: ['njk', 'md'],
htmlTemplateEngine: 'njk',
markdownTemplateEngine: 'njk',
passthroughFileCopy: true
}
}

View file

@ -1,5 +1,5 @@
import meta from '../src/data/meta'
import members from '../src/data/members'
import meta from '../../src/data/meta'
import members from '../../src/data/members'
export const redirect = site => {
const location = site && site.url ? site.url : meta.url

View file

@ -1,7 +1,7 @@
const gulp = require('gulp')
const sass = require('gulp-sass')
gulp.task('css', function() {
gulp.task('styles', function() {
return gulp
.src('./src/assets/styles/*.scss')
.pipe(

View file

@ -1,7 +1,7 @@
{
"name": "webring",
"version": "1.0.0",
"description": "A boilerplate for hosting a webring on github/netlify",
"description": "A boilerplate for hosting a webring community",
"author": "Max Böck",
"license": "MIT",
"repository": {
@ -9,10 +9,10 @@
"url": "http://github.com/maxboeck/webring"
},
"scripts": {
"start": "gulp build && eleventy serve",
"start": "gulp build && eleventy --serve && yarn run serve:lambda",
"build": "gulp build && yarn run build:lambda",
"serve:lambda": "netlify-lambda serve lambda",
"build:lambda": "netlify-lambda build lambda"
"serve:lambda": "netlify-lambda serve _lambda",
"build:lambda": "netlify-lambda build _lambda"
},
"dependencies": {
"@11ty/eleventy": "^0.8.2",

View file

@ -0,0 +1,4 @@
* {
margin: 0;
padding: 0;
}

View file

@ -0,0 +1,4 @@
---
layout: base
---
<h1>{{ meta.title }}</h1>

18
src/layouts/base.njk Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{{ meta.title }}</title>
<link rel="stylesheet" href="{{ '/assets/styles/main.css' | url }}">
</head>
<body>
{{ content | safe }}
</body>
</html>