{{ substr .hash 0 10 }}...{{ substr .hash $length 5 }}
+
diff --git a/.gitignore b/.gitignore
index 6789b40..3a106de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,9 +27,7 @@ stroke*.svg
public
dist
/src/resources
-/src/data
/src/content
-/src/layouts/partials/indexes
/src/static/fonts
/src/static/app.css
/src/static/app.js
diff --git a/Makefile b/Makefile
deleted file mode 100644
index b9a954c..0000000
--- a/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-build:
- npm --version
- node --version
- npm install
- npm run lint
- npm run build
\ No newline at end of file
diff --git a/package.json b/package.json
index 4de646d..f2ebcee 100644
--- a/package.json
+++ b/package.json
@@ -3,9 +3,9 @@
"version": "1.0.0",
"private": true,
"dependencies": {
- "ipfs-css": "^0.5.2",
- "lunr": "^2.3.0",
- "tachyons": "^4.10.0"
+ "ipfs-css": "^0.12.0",
+ "lunr": "^2.3.6",
+ "tachyons": "^4.11.1"
},
"scripts": {
"start": "node ./scripts/dev.js",
@@ -18,24 +18,22 @@
"build:css": "postcss --no-map --use postcss-import cssnano -o src/static/app.css src/css/*.css",
"build:js": "browserify -g uglifyify src/js/app.js -o src/static/app.js",
"build:data": "node ./scripts/make-data.js",
- "build:hugo": "hugo -s src -d ../public --cleanDestinationDir",
- "build:minify": "html-minifier --input-dir=./public --output-dir=./public --file-ext=html --collapse-whitespace --remove-comments"
+ "build:hugo": "hugo -s src -d ../public --cleanDestinationDir --minify --gc"
},
"devDependencies": {
- "babel-eslint": "^8.2.6",
- "browserify": "^16.2.2",
- "chokidar": "^2.0.4",
- "cssnano": "^4.0.1",
- "ecstatic": "^3.2.1",
- "fs-extra": "^6.0.1",
- "html-minifier": "^3.5.19",
- "hugo-bin": "^0.29.0",
- "node-yaml": "^3.1.1",
- "npm-run-all": "^4.1.3",
- "postcss-cli": "^5.0.1",
- "postcss-import": "^11.1.0",
+ "babel-eslint": "^10.0.1",
+ "browserify": "^16.2.3",
+ "chokidar": "^2.1.5",
+ "cssnano": "^4.1.10",
+ "ecstatic": "^4.1.2",
+ "fs-extra": "^7.0.1",
+ "hugo-bin": "^0.43.4",
+ "node-yaml": "^3.2.0",
+ "npm-run-all": "^4.1.5",
+ "postcss-cli": "^6.1.2",
+ "postcss-import": "^12.0.1",
"shx": "^0.3.2",
- "standard": "^11.0.1",
+ "standard": "^12.0.1",
"uglifyify": "^5.0.1",
"watch": "^1.0.2"
},
diff --git a/scripts/data.js b/scripts/data.js
index 6b6932d..6965e32 100644
--- a/scripts/data.js
+++ b/scripts/data.js
@@ -1,23 +1,34 @@
const fs = require('fs')
-const path = require('path')
+const { join } = require('path')
const yaml = require('node-yaml')
-const { sortAbc } = require('./utils')
-const dataDir = path.join(__dirname, '../data')
+const { sortAbc, sortInv, slugify } = require('./utils')
+const dir = join(__dirname, '../data')
const trimIfExists = (str) => str ? str.trim() : undefined
-const files = fs.readdirSync(dataDir)
- .map(file => path.join(dataDir, file))
+module.exports = fs.readdirSync(dir)
+ .map(file => join(dir, file))
.map(file => yaml.readSync(file))
.map(file => {
- file.content = file.content.map(({ title, description, ...file }) => ({
+ file.slug = slugify(file.title)
+ file.type = 'category'
+
+ file.content = file.content.map(({ title, description, ...meta }, i) => ({
+ ...meta,
title: trimIfExists(title),
description: trimIfExists(description),
- ...file
+ category: file.slug,
+ color: file.color,
+ index: i
}))
+ let sort = (a, b) => sortAbc(a.title, b.title)
+
+ if (file.slug === 'articles') {
+ sort = (a, b) => sortInv(a.date, b.date)
+ }
+
+ file.content = file.content.sort(sort)
return file
})
.sort((a, b) => sortAbc(a.title, b.title))
-
-module.exports = files
diff --git a/scripts/make-data.js b/scripts/make-data.js
index 967e70e..9a8ff93 100644
--- a/scripts/make-data.js
+++ b/scripts/make-data.js
@@ -1,126 +1,50 @@
const lunr = require('lunr')
const fs = require('fs-extra')
-const path = require('path')
-const { slugify, capitalize, sortAbc } = require('./utils')
+const { join } = require('path')
-const dataDir = path.join(__dirname, '../src/data')
-const contentDir = path.join(__dirname, '../src/content')
-const indexesDir = path.join(__dirname, '../src/layouts/partials/indexes')
+function getData () {
+ let data = require('./data')
-const processDataType = (data) => {
- const content = data.content.map(info => {
- const { website, ...more } = info
-
- return {
- website: website,
- categories: [data.title.toLowerCase()],
- ...more
- }
+ data.push({
+ title: 'Awesome IPFS',
+ slug: '_index',
+ content: data
+ .reduce((arr, cat) => arr.concat(cat.content), [])
+ .map((el, i) => ({
+ ...el,
+ index: i
+ }))
})
- delete data.content
-
- return {
- info: { ...data },
- content: content
- }
+ data.forEach(makeIndex)
+ return data
}
-const writeContentFile = (data) => {
- const basename = slugify(data.title)
- const filename = path.join(contentDir, `${basename}.md`)
-
- fs.writeFileSync(filename, JSON.stringify(data))
-}
-
-const makeIndex = (data) => {
- const indexes = { 'index': [] }
-
- const checkField = (field, el) => {
- if (Array.isArray(el[field])) {
- el[field].forEach(t => {
- const key = `${field}_${t}`
-
- if (indexes[key]) {
- indexes[key].push(el.index)
- } else {
- indexes[key] = [el.index]
- }
- })
- }
- }
-
- data.forEach(el => {
- indexes.index.push(el.index)
- checkField('tags', el)
- checkField('categories', el)
- })
-
- data = data.map(({index, title, description = '', tags = [], categories = []}) => ({
+function makeIndex (category) {
+ const data = category.content.map(({ index, title, description = '', tags = [], category = '' }) => ({
ref: index,
- data: `${title} ${description} ${tags.join(' ')} ${categories.join(' ')}`
+ data: `${title} ${description} ${tags.join(' ')} ${category}`
}))
- for (const index in indexes) {
- const idx = lunr(function () {
- this.ref('ref')
- this.field('data')
-
- indexes[index].map(i => data[i]).forEach(this.add.bind(this))
- })
-
- const file = path.join(indexesDir, index + '.html')
- const json = JSON.stringify(idx).replace(`'`, `\\'`)
-
- fs.writeFileSync(file, ``)
- }
+ category.index = lunr(function () {
+ this.ref('ref')
+ this.field('data')
+ data.forEach(this.add.bind(this))
+ })
}
const process = () => {
- fs.ensureDirSync(dataDir)
- fs.ensureDirSync(contentDir)
- fs.ensureDirSync(indexesDir)
- fs.emptyDirSync(dataDir)
- fs.emptyDirSync(contentDir)
- fs.emptyDirSync(indexesDir)
+ const dir = join(__dirname, '../src/content')
+ fs.ensureDirSync(dir)
+ fs.emptyDirSync(dir)
- let data = []
- let types = []
- let typesObj = {}
+ const data = getData()
- require('./data')
- .map(processDataType)
- .forEach(({info, content}) => {
- types.push(info)
- data.push(content)
- })
-
- data = data.reduce((a, v) => a.concat(v), [])
- .sort((a, b) => sortAbc(a.title, b.title))
- .map((v, i) => { v.index = i; return v })
-
- data.forEach(writeContentFile)
- makeIndex(data)
-
- types = types.map(t => {
- t.title = capitalize(t.title)
- return t
- }).sort((a, b) => {
- if (a.weight < b.weight) {
- return -1
- }
-
- if (a.weight > b.weight) {
- return 1
- }
-
- return 0
- }).forEach(type => {
- typesObj[type.title.toLowerCase()] = type
- })
-
- const pt = path.join(dataDir, 'categories.json')
- fs.writeFileSync(pt, JSON.stringify(typesObj))
+ for (const { index, slug, ...meta } of data) {
+ const filename = join(dir, slug + '.md')
+ fs.writeFileSync(filename, `${JSON.stringify(meta)}
+`)
+ }
}
process()
diff --git a/scripts/make-readme.js b/scripts/make-readme.js
index 9aae10e..34b5179 100644
--- a/scripts/make-readme.js
+++ b/scripts/make-readme.js
@@ -3,18 +3,12 @@ const path = require('path')
const files = require('./data')
const readme = path.join(__dirname, '../README.md')
const template = path.join(__dirname, 'readme-template.md')
-const { slugify, sortInv, sortAbc } = require('./utils')
+const { slugify } = require('./utils')
const toc = files.map(cat => `- [${cat.title}](#${slugify(cat.title)})`).join('\n')
const sections = files.map(category => {
- let sort = (a, b) => sortAbc(a.title, b.title)
-
- if (category.title === 'Articles') {
- sort = (a, b) => sortInv(a.date, b.date)
- }
-
- const content = category.content.sort(sort).map(item => {
+ const content = category.content.map(item => {
let block = '- '
let mainUrl = ''
diff --git a/scripts/utils.js b/scripts/utils.js
index 72bd658..3573363 100644
--- a/scripts/utils.js
+++ b/scripts/utils.js
@@ -20,12 +20,9 @@ const slugify = (text) => text.toString()
.replace(/^-+/, '')
.replace(/-+$/, '')
-const capitalize = (text) => `${text.charAt(0).toUpperCase()}${text.slice(1).toLowerCase()}`
-
module.exports = {
sort,
sortInv,
sortAbc,
- slugify,
- capitalize
+ slugify
}
diff --git a/src/layouts/_default/baseof.html b/src/layouts/_default/baseof.html
index 875a157..ed673f5 100644
--- a/src/layouts/_default/baseof.html
+++ b/src/layouts/_default/baseof.html
@@ -11,15 +11,12 @@
{{ substr .hash 0 10 }}...{{ substr .hash $length 5 }}
+