Move posts from Wordpress to physical markdown
This commit is contained in:
1 parent
e828f9f590
commit
c8c5981bd3
147 files changed
+6219
-98
No files matched your search
@@ -104,7 +104,7 @@ class PostCache {
|
||||
|
||||
const cache = new PostCache();
|
||||
|
||||
module.exports = async function() {
|
||||
await cache.fetchLatest();
|
||||
return cache;
|
||||
}
|
||||
// module.exports = async function() {
|
||||
// await cache.fetchLatest();
|
||||
// return cache;
|
||||
// }
|
||||
@@ -0,0 +1,46 @@
|
||||
const postCache = require('./_postData');
|
||||
|
||||
const dateSort = (a, b) => new Date(b.date) - new Date(a.date);
|
||||
|
||||
const mapComment = comment => {
|
||||
return ({
|
||||
author: {
|
||||
name: comment.author_name,
|
||||
avatars: comment.author_avatar_urls,
|
||||
url: comment.author_url,
|
||||
},
|
||||
content: comment.content.rendered,
|
||||
canonical: comment.meta.url,
|
||||
date: comment.date,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports = async () => {
|
||||
// const cache = await postCache();
|
||||
|
||||
// const posts = Object.values(cache.posts)
|
||||
// .sort(dateSort)
|
||||
// .map(post => ({
|
||||
// ...post,
|
||||
// comments: Object.values(post.comments)
|
||||
// .sort(dateSort)
|
||||
// .reduce((comments, comment) => {
|
||||
// if (!comments[comment.type]) {
|
||||
// comments[comment.type] = [];
|
||||
// }
|
||||
|
||||
// comments[comment.type].push(mapComment(comment));
|
||||
// return comments;
|
||||
// }, { like: [], reply: [], repost: [] }),
|
||||
// tags: post.tags.map(tag => ({
|
||||
// name: cache.tags[tag].name,
|
||||
// slug: cache.tags[tag].slug,
|
||||
// link: cache.tags[tag].link
|
||||
// }))
|
||||
// }));
|
||||
|
||||
// return posts;
|
||||
|
||||
return [];
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
const postCache = require('./_postData');
|
||||
|
||||
const dateSort = (a, b) => new Date(b.date) - new Date(a.date);
|
||||
|
||||
const mapComment = comment => {
|
||||
return ({
|
||||
author: {
|
||||
name: comment.author_name,
|
||||
avatars: comment.author_avatar_urls,
|
||||
url: comment.author_url,
|
||||
},
|
||||
content: comment.content.rendered,
|
||||
canonical: comment.meta.url,
|
||||
date: comment.date,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports = async () => {
|
||||
const cache = await postCache();
|
||||
|
||||
const posts = Object.values(cache.posts)
|
||||
.sort(dateSort)
|
||||
.map(post => ({
|
||||
...post,
|
||||
comments: Object.values(post.comments)
|
||||
.sort(dateSort)
|
||||
.reduce((comments, comment) => {
|
||||
if (!comments[comment.type]) {
|
||||
comments[comment.type] = [];
|
||||
}
|
||||
|
||||
comments[comment.type].push(mapComment(comment));
|
||||
return comments;
|
||||
}, { like: [], reply: [], repost: [] }),
|
||||
tags: post.tags.map(tag => ({
|
||||
name: cache.tags[tag].name,
|
||||
slug: cache.tags[tag].slug,
|
||||
link: cache.tags[tag].link
|
||||
}))
|
||||
}));
|
||||
|
||||
return posts;
|
||||
};
|
||||
+10
-8
@@ -2,14 +2,16 @@ const postCache = require('./_postData');
|
||||
|
||||
|
||||
module.exports = async () => {
|
||||
const cache = await postCache();
|
||||
// const cache = await postCache();
|
||||
|
||||
return Object.values(cache.tags).map(tag => {
|
||||
const posts = Object.values(cache.posts).filter(post => post.tags.includes(tag.id)).sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||
// return Object.values(cache.tags).map(tag => {
|
||||
// const posts = Object.values(cache.posts).filter(post => post.tags.includes(tag.id)).sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||
|
||||
return {
|
||||
...tag,
|
||||
posts,
|
||||
}
|
||||
});
|
||||
// return {
|
||||
// ...tag,
|
||||
// posts,
|
||||
// }
|
||||
// });
|
||||
|
||||
return [];
|
||||
};
|
||||
Reference in new issue
Block a user