no-css-blog
Advanced tools
Comparing version 0.1.5 to 0.1.6
42
index.js
@@ -74,12 +74,8 @@ #!/usr/bin/env node | ||
const tags = ls('posts'); | ||
const posts = ls('posts') | ||
.map((tag) => | ||
ls(`posts/${tag}`).map((post) => ({ | ||
tag, | ||
post, | ||
createdAt: new Date(post.substring(0, 10)), | ||
markdown: cat(`posts/${tag}/${post}/post.md`), | ||
})), | ||
) | ||
.map((post) => ({ | ||
post: post.replace('.md', ''), | ||
createdAt: new Date(post.substring(0, 10)), | ||
markdown: cat(`posts/${post}`), | ||
})) | ||
.flat(); | ||
@@ -91,11 +87,7 @@ | ||
'<!-- INDEX -->', | ||
tags | ||
.map((tag) => { | ||
let item = `<h3>${tag}</h3><ul>`; | ||
for (const post of posts.filter((post) => post.tag === tag).sort((a, b) => b.createdAt - a.createdAt)) { | ||
item += `<li><pre>${post.createdAt.toISOString().substring(0, 10)} <a href="/${tag}/${post.post.substring(11)}.html">${post.post.substring(11)}</a></pre></li>`; | ||
} | ||
item += '</ul>'; | ||
return item; | ||
}) | ||
posts | ||
.map( | ||
(post) => | ||
`<li><pre>${post.createdAt.toISOString().substring(0, 10)} <a href="/${post.post.substring(11)}.html">${post.post.substring(11)}</a></pre></li>`, | ||
) | ||
.join(''), | ||
@@ -108,12 +100,5 @@ ); | ||
for (const post of posts.sort((a, b) => b.createdAt - a.createdAt)) { | ||
mkdir(`build/${post.tag}`); | ||
mkdir(`build/${post.tag}/images`); | ||
const html = convertMarkdownToHTML(post.markdown); | ||
const minifiedHTML = minifyHTML(postLayout.replace('<!-- TITLE -->', post.post.substring(11)).replace('<!-- BODY -->', html)); | ||
write(`build/${post.tag}/${post.post.substring(11)}.html`, minifiedHTML); | ||
for (const image of ls(`./posts/${post.tag}/${post.post}/images`)) { | ||
cp(`./posts/${post.tag}/${post.post}/images/${image}`, `./build/${post.tag}/images/${image}`); | ||
} | ||
write(`build/${post.post.substring(11)}.html`, minifiedHTML); | ||
} | ||
@@ -130,6 +115,3 @@ | ||
`<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${posts | ||
.map( | ||
(post) => | ||
`<url><loc>https://blog.yuru.cam/${post.tag}/${post.post.substring(11)}.html</loc><lastmod>${post.post.substring(0, 10)}</lastmod></url>`, | ||
) | ||
.map((post) => `<url><loc>https://blog.yuru.cam/${post.post.substring(11)}.html</loc><lastmod>${post.post.substring(0, 10)}</lastmod></url>`) | ||
.join('')}</urlset>`, | ||
@@ -136,0 +118,0 @@ ); |
{ | ||
"name": "no-css-blog", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A tool to generate a blog without CSS", | ||
@@ -5,0 +5,0 @@ "author": "rhea-so", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5201
99