Skip to content

Commit 00e1d8f

Browse files
committed
Scrappy libre.fm modifications
1 parent 72b21d2 commit 00e1d8f

19 files changed

+7567
-6520
lines changed

.eleventy.js

+110-98
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require("dotenv").config();
22

3-
const cleanCSS = require("clean-css");
3+
// const cleanCSS = require("clean-css");
44
const fs = require("fs");
55
const pluginRSS = require("@11ty/eleventy-plugin-rss");
6-
const localImages = require("eleventy-plugin-local-images");
7-
const lazyImages = require("eleventy-plugin-lazyimages");
6+
// const localImages = require("eleventy-plugin-local-images");
7+
// const lazyImages = require("eleventy-plugin-lazyimages");
88
const ghostContentAPI = require("@tryghost/content-api");
99

10-
const htmlMinTransform = require("./src/transforms/html-min-transform.js");
10+
// const htmlMinTransform = require("./src/transforms/html-min-transform.js");
1111

1212
// Init Ghost API
1313
const api = new ghostContentAPI({
@@ -23,29 +23,29 @@ const stripDomain = url => {
2323

2424
module.exports = function(config) {
2525
// Minify HTML
26-
config.addTransform("htmlmin", htmlMinTransform);
26+
// config.addTransform("htmlmin", htmlMinTransform);
2727

2828
// Assist RSS feed template
2929
config.addPlugin(pluginRSS);
3030

3131
// Apply performance attributes to images
32-
config.addPlugin(lazyImages, {
33-
cacheFile: ""
34-
});
32+
//config.addPlugin(lazyImages, {
33+
//cacheFile: ""
34+
//});
3535

3636
// Copy images over from Ghost
37-
config.addPlugin(localImages, {
38-
distPath: "dist",
39-
assetPath: "/assets/images",
40-
selector: "img",
41-
attribute: "data-src", // Lazy images attribute
42-
verbose: false
43-
});
37+
// config.addPlugin(localImages, {
38+
// distPath: "dist",
39+
// assetPath: "/assets/images",
40+
// selector: "img",
41+
// attribute: "data-src", // Lazy images attribute
42+
// verbose: false
43+
// });
4444

4545
// Inline CSS
46-
config.addFilter("cssmin", code => {
47-
return new cleanCSS({}).minify(code).styles;
48-
});
46+
//config.addFilter("cssmin", code => {
47+
//return new cleanCSS({}).minify(code).styles;
48+
//});
4949

5050
config.addFilter("getReadingTime", text => {
5151
const wordsPerMinute = 200;
@@ -84,6 +84,8 @@ module.exports = function(config) {
8484

8585
return collection;
8686
});
87+
88+
8789

8890
// Get all posts
8991
config.addCollection("posts", async function(collection) {
@@ -97,12 +99,22 @@ module.exports = function(config) {
9799
});
98100

99101
collection.forEach(post => {
100-
post.url = stripDomain(post.url);
101102
post.primary_author.url = stripDomain(post.primary_author.url);
102103
post.tags.map(tag => (tag.url = stripDomain(tag.url)));
103104

104105
// Convert publish date into a Date object
105106
post.published_at = new Date(post.published_at);
107+
108+
var MyDate = post.published_at;
109+
var MyDateString;
110+
111+
MyDate.setDate(MyDate.getDate());
112+
113+
MyDateString = MyDate.getFullYear() + "/" + ('0' + (MyDate.getMonth() + 1)).slice(-2);
114+
115+
post.url = "/" + MyDateString + stripDomain(post.url);
116+
117+
106118
});
107119

108120
// Bring featured post to the top of the list
@@ -111,89 +123,89 @@ module.exports = function(config) {
111123
return collection;
112124
});
113125

114-
// Get all authors
115-
config.addCollection("authors", async function(collection) {
116-
collection = await api.authors
117-
.browse({
118-
limit: "all"
119-
})
120-
.catch(err => {
121-
console.error(err);
122-
});
123-
124-
// Get all posts with their authors attached
125-
const posts = await api.posts
126-
.browse({
127-
include: "authors",
128-
limit: "all"
129-
})
130-
.catch(err => {
131-
console.error(err);
132-
});
133-
134-
// Attach posts to their respective authors
135-
collection.forEach(async author => {
136-
const authorsPosts = posts.filter(post => {
137-
post.url = stripDomain(post.url);
138-
return post.primary_author.id === author.id;
139-
});
140-
if (authorsPosts.length) author.posts = authorsPosts;
141-
142-
author.url = stripDomain(author.url);
143-
});
144-
145-
return collection;
146-
});
126+
// // Get all authors
127+
// config.addCollection("authors", async function(collection) {
128+
// collection = await api.authors
129+
// .browse({
130+
// limit: "all"
131+
// })
132+
// .catch(err => {
133+
// console.error(err);
134+
// });
135+
//
136+
// // Get all posts with their authors attached
137+
// const posts = await api.posts
138+
// .browse({
139+
// include: "authors",
140+
// limit: "all"
141+
// })
142+
// .catch(err => {
143+
// console.error(err);
144+
// });
145+
//
146+
// // Attach posts to their respective authors
147+
// collection.forEach(async author => {
148+
// const authorsPosts = posts.filter(post => {
149+
// post.url = stripDomain(post.url);
150+
// return post.primary_author.id === author.id;
151+
// });
152+
// if (authorsPosts.length) author.posts = authorsPosts;
153+
//
154+
// author.url = stripDomain(author.url);
155+
// });
156+
//
157+
// return collection;
158+
// });
147159

148160
// Get all tags
149-
config.addCollection("tags", async function(collection) {
150-
collection = await api.tags
151-
.browse({
152-
include: "count.posts",
153-
limit: "all"
154-
})
155-
.catch(err => {
156-
console.error(err);
157-
});
158-
159-
// Get all posts with their tags attached
160-
const posts = await api.posts
161-
.browse({
162-
include: "tags,authors",
163-
limit: "all"
164-
})
165-
.catch(err => {
166-
console.error(err);
167-
});
168-
169-
// Attach posts to their respective tags
170-
collection.forEach(async tag => {
171-
const taggedPosts = posts.filter(post => {
172-
post.url = stripDomain(post.url);
173-
return post.primary_tag && post.primary_tag.slug === tag.slug;
174-
});
175-
if (taggedPosts.length) tag.posts = taggedPosts;
176-
177-
tag.url = stripDomain(tag.url);
178-
});
179-
180-
return collection;
181-
});
161+
// config.addCollection("tags", async function(collection) {
162+
// collection = await api.tags
163+
// .browse({
164+
// include: "count.posts",
165+
// limit: "all"
166+
// })
167+
// .catch(err => {
168+
// console.error(err);
169+
// });
170+
//
171+
// // Get all posts with their tags attached
172+
// // const posts = await api.posts
173+
// // .browse({
174+
// // include: "tags,authors",
175+
// // limit: "all"
176+
// // })
177+
// // .catch(err => {
178+
// // console.error(err);
179+
// // });
180+
//
181+
// // Attach posts to their respective tags
182+
// // collection.forEach(async tag => {
183+
// // const taggedPosts = posts.filter(post => {
184+
// // post.url = stripDomain(post.url);
185+
// // return post.primary_tag && post.primary_tag.slug === tag.slug;
186+
// // });
187+
// // if (taggedPosts.length) tag.posts = taggedPosts;
188+
// //
189+
// // tag.url = stripDomain(tag.url);
190+
// // });
191+
//
192+
// return collection;
193+
// });
182194

183195
// Display 404 page in BrowserSnyc
184-
config.setBrowserSyncConfig({
185-
callbacks: {
186-
ready: (err, bs) => {
187-
const content_404 = fs.readFileSync("dist/404.html");
188-
189-
bs.addMiddleware("*", (req, res) => {
190-
// Provides the 404 content without redirect.
191-
res.write(content_404);
192-
res.end();
193-
});
194-
}
195-
}
196-
});
196+
// config.setBrowserSyncConfig({
197+
// callbacks: {
198+
// ready: (err, bs) => {
199+
// const content_404 = fs.readFileSync("dist/404.html");
200+
//
201+
// bs.addMiddleware("*", (req, res) => {
202+
// // Provides the 404 content without redirect.
203+
// res.write(content_404);
204+
// res.end();
205+
// });
206+
// }
207+
// }
208+
// });
197209

198210
// Eleventy configuration
199211
return {

.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
GHOST_API_URL=https://eleventy.ghost.io
2-
GHOST_CONTENT_API_KEY=5a562eebab8528c44e856a3e0a
1+
GHOST_API_URL=http://localhost:2368
2+
GHOST_CONTENT_API_KEY=1ba35acab36b0038fdd5ec4dbb
33
SITE_URL=http://localhost:8080

.yarn/install-state.gz

617 KB
Binary file not shown.

.yarnrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

src/404.njk

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ permalink: 404.html
44

55
{% extends 'layouts/default.njk' %}
66

7-
{% set codeinjection_head = doc.codeinjection_head %}
8-
{% set codeinjection_foot = doc.codeinjection_foot %}
9-
107
{% set title = "Error 404" %}
118

129
{% block content %}

0 commit comments

Comments
 (0)