blog-engine-sac
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -6,2 +6,3 @@ export { createAboutHtml }; | ||
import { createFooterHtml } from "./footer.html.js"; | ||
import {makeBackGroundPicture} from "./images.js"; | ||
@@ -30,5 +31,5 @@ | ||
<header class="masthead" style="background-image: url('images/about-bg.jpg')"> | ||
<div class="overlay"></div> | ||
<div class="container"> | ||
<header class="masthead"> | ||
${makeBackGroundPicture(`about-bg`)} | ||
<div class="container position-absolute"> | ||
<div class="row"> | ||
@@ -52,6 +53,2 @@ <div class="col-lg-8 col-md-10 mx-auto"> | ||
</div> | ||
<hr> | ||
<hr> | ||
${createFooterHtml(options)} | ||
@@ -58,0 +55,0 @@ </body> |
@@ -8,2 +8,3 @@ export { createCategoryHtml }; | ||
import {makeUrl, escapeHtml} from "./links.js"; | ||
import {makeBackGroundPicture} from "./images.js"; | ||
@@ -32,19 +33,15 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="description" content=""> | ||
<title>Blog</title> | ||
<title>${categoryName}</title> | ||
${styleSheets(options)} | ||
</head> | ||
<body> | ||
${createHeaderHtml({ ...options, topLevel: false })} | ||
<header class="masthead" style="background-image: url('../images/home-bg.jpg')"> | ||
<div class="overlay"></div> | ||
<header class="masthead"> | ||
${makeBackGroundPicture(`home-bg`)} | ||
<div class="container position-absolute"> | ||
<div class="container"> | ||
@@ -62,4 +59,3 @@ <div class="row"> | ||
<!-- Main Content --> | ||
<div class="container"> | ||
<main class="container"> | ||
<div class="row"> | ||
@@ -72,7 +68,3 @@ <div class="col-lg-8 col-md-10 mx-auto"> | ||
</div> | ||
</div> | ||
<hr> | ||
<hr> | ||
</main> | ||
${createFooterHtml(options)} | ||
@@ -79,0 +71,0 @@ </body> |
export { createContactHtml }; | ||
import { styleSheets } from "./styles.html.js"; | ||
import {makeBackGroundPicture} from "./images.js"; | ||
import { createHeaderHtml } from "./header.html.js"; | ||
@@ -20,22 +21,18 @@ import { createFooterHtml } from "./footer.html.js"; | ||
</head> | ||
<body> | ||
${createHeaderHtml({ ...options, topLevel: true })} | ||
<!-- Page Header --> | ||
<header class="masthead" style="background-image: url('images/contact-bg.jpg')"> | ||
<div class="overlay"></div> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-lg-8 col-md-10 mx-auto"> | ||
<div class="page-heading"> | ||
<h1>Contact Me</h1> | ||
<span class="subheading"></span> | ||
<header class="masthead"> | ||
${makeBackGroundPicture(`contact-bg`)} | ||
<div class="container position-absolute"> | ||
<div class="row"> | ||
<div class="col-lg-8 col-md-10 mx-auto"> | ||
<div class="page-heading"> | ||
<h1>Contact Me</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
<!-- Main Content --> | ||
<div class="container"> | ||
<main class="container"> | ||
<div class="row"> | ||
@@ -47,5 +44,4 @@ <div class="col-lg-8 col-md-10 mx-auto"> | ||
</div> | ||
</div> | ||
</main> | ||
<hr> | ||
${createFooterHtml(options)} | ||
@@ -52,0 +48,0 @@ </body> |
@@ -7,4 +7,3 @@ export {createFooterHtml}; | ||
return ` | ||
<footer> | ||
<div class="container"> | ||
<footer class="container"> | ||
<div class="row"> | ||
@@ -16,3 +15,2 @@ <div class="col-lg-8 col-md-10 mx-auto"> | ||
</div> | ||
</div> | ||
</footer> | ||
@@ -19,0 +17,0 @@ `; |
export { createHeaderHtml }; | ||
import {indexFileName} from "./links.js"; | ||
import { translate } from "../translations/translate.js"; | ||
const translations = { | ||
fr: { | ||
Home: `Accueil`, | ||
About: `À propos`, | ||
Contact: `Contact`, | ||
} | ||
} | ||
const traduire = ((translations, lang, key) => { | ||
if (translations[lang]) { | ||
if (translations[lang][key]) { | ||
return translations[lang][key]; | ||
} | ||
} | ||
return key; | ||
}) | ||
.bind(undefined, translations); | ||
const createHeaderHtml = (options) => { | ||
@@ -33,9 +18,9 @@ const {searchCode, topLevel, lang, defaultLang} = options; | ||
<li class="nav-item"> | ||
<a class="nav-link" href="${prePath}/${indexFileName(lang, defaultLang)}">${traduire(lang, `Home`)}</a> | ||
<a class="nav-link" href="${prePath}/${indexFileName(lang, defaultLang)}">${translate(lang, `Home`)}</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="${prePath}/about.html">${traduire(lang, `About`)}</a> | ||
<a class="nav-link" href="${prePath}/about.html">${translate(lang, `About`)}</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="${prePath}/contact.html">${traduire(lang, `Contact`)}</a> | ||
<a class="nav-link" href="${prePath}/contact.html">${translate(lang, `Contact`)}</a> | ||
</li> | ||
@@ -42,0 +27,0 @@ <script type="module">${searchCode}</script> |
@@ -8,3 +8,6 @@ export { createIndexHtml }; | ||
import {linkFromCategory, linkFromPost, makeUrl, escapeHtml} from "./links.js"; | ||
import {makeBackGroundPicture} from "./images.js"; | ||
import { translate } from "../translations/translate.js"; | ||
const createIndexHtml = (options) => { | ||
@@ -25,18 +28,9 @@ const { body, title, author, description, posts, categories, lang, } = options; | ||
</span> | ||
<p class="post-meta">Posted by | ||
<p class="post-meta">${translate(lang, `Posted by`)} | ||
${post.author} | ||
on <time>${post.creationDateString}</time></p> | ||
<time>${post.creationDateString}</time></p> | ||
</a>`; | ||
// const postsPreview = `<hr> | ||
// <div class="post-preview"> | ||
// <a href="${link}"> | ||
// ${post.body.split(/\r?\n/).splice(0, MAX_LINES_PREVIEW).join("\n")} | ||
// </a> | ||
// </div> | ||
// <hr>`; | ||
}); | ||
const categoriesLinks = Object.entries(categories).map(function ([categoryName, posts]) { | ||
return `<li>${linkFromCategory(categoryName)}</li>`; | ||
}).join(``); | ||
return `<!DOCTYPE html> | ||
@@ -49,3 +43,3 @@ <html lang="${lang}"> | ||
<meta name="author" content="${author}"> | ||
<title>Blog</title> | ||
<title>${options.mainTitle}</title> | ||
${styleSheets(options)} | ||
@@ -56,17 +50,17 @@ </head> | ||
${createHeaderHtml({ ...options, topLevel: true })} | ||
<header class="masthead" style="background-image: url('images/home-bg.jpg')"> | ||
<div class="overlay"></div> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-lg-8 col-md-10 mx-auto"> | ||
<div class="site-heading"> | ||
<h1>Blog</h1> | ||
<span class="subheading">Sub Heading Text</span> | ||
<header class="masthead"> | ||
${makeBackGroundPicture(`home-bg`)} | ||
<div class="container position-absolute"> | ||
<div class="row"> | ||
<div class="col-lg-8 col-md-10 mx-auto"> | ||
<div class="site-heading"> | ||
<h1>${options.mainTitle}</h1> | ||
<span class="subheading">${options.subTitle}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
<div class="container"> | ||
<main class="container"> | ||
<div class="row"> | ||
@@ -83,7 +77,12 @@ <div class="col-lg-8 col-md-10 mx-auto"> | ||
</div> | ||
</div> | ||
<hr> | ||
<ul>${categoriesLinks}</ul> | ||
<hr> | ||
<div class="row"> | ||
<div class="col-lg-8 col-md-10 mx-auto"> | ||
<h3>Categories</h3> | ||
<ul> | ||
${Object.entries(categories).map(function ([categoryName, posts]) { | ||
return `<li>${linkFromCategory(categoryName)}</li>`; | ||
}).join(``)} | ||
</ul> | ||
</div> | ||
</main> | ||
${createFooterHtml(options)} | ||
@@ -90,0 +89,0 @@ </body> |
@@ -11,5 +11,5 @@ export { makeUrl, linkFromPost, linkFromCategory, escapeHtml, indexFileName}; | ||
const linkFromPost = (post) => { | ||
const linkFromPost = (post, attributes=``) => { | ||
const {base, title} = post; | ||
return `<a href="${makeUrl(base)}">${escapeHtml(title)}</a>`; | ||
return `<a href="${makeUrl(base)}" ${attributes}>${escapeHtml(title)}</a>`; | ||
}; | ||
@@ -16,0 +16,0 @@ |
@@ -6,6 +6,8 @@ export {createPostHtml}; | ||
import { linkFromPost, linkFromCategory } from "./links.js"; | ||
import {makeBackGroundPicture} from "./images.js"; | ||
import { translate } from "../translations/translate.js"; | ||
const createPostHtml = (options) => { | ||
const { body, title, author, description, creationDateString, modifiedDateString, translations } = options; | ||
const { body, title, author, description, creationDateString, modifiedDateString, translations, lang } = options; | ||
let lastEdit; | ||
@@ -16,3 +18,3 @@ | ||
} else { | ||
lastEdit = `<p>Last edit: <time>${modifiedDateString}</time></p>`; | ||
lastEdit = `<p class="meta">${translate(lang, `Last edit`)} <time>${modifiedDateString}</time></p>`; | ||
} | ||
@@ -27,4 +29,3 @@ | ||
return `<!DOCTYPE html> | ||
<html lang="en"> | ||
<html lang="${lang}"> | ||
<head> | ||
@@ -42,4 +43,5 @@ | ||
${createHeaderHtml({ ...options, topLevel: false })} | ||
<header class="masthead" style="background-image: url('../images/post-bg.jpg')"> | ||
<div class="overlay"></div> | ||
<header class="masthead"> | ||
${makeBackGroundPicture(`post-bg`)} | ||
<div class="container position-absolute"> | ||
<div class="container"> | ||
@@ -50,7 +52,6 @@ <div class="row"> | ||
<h1>${title}</h1> | ||
<!-- <h2 class="subheading">Problems look mighty small from 150 miles up</h2> --> | ||
<span class="meta">Posted by | ||
<p class="meta">${translate(lang, `Posted by`)} | ||
${author} | ||
${creationDateString} | ||
</span> | ||
<time>${creationDateString}</time> | ||
</p>${lastEdit} | ||
</div> | ||
@@ -62,4 +63,3 @@ </div> | ||
<article> | ||
<div class="container"> | ||
<main class="container"> | ||
<div class="row"> | ||
@@ -69,6 +69,5 @@ <div class="col-lg-8 col-md-10 mx-auto"> | ||
</div> | ||
<div class="col-lg-8 col-md-10 mx-auto"> | ||
${lastEdit} | ||
<article class="col-lg-8 col-md-10 mx-auto"> | ||
${body} | ||
</div> | ||
</article> | ||
</div> | ||
@@ -85,7 +84,5 @@ <hr> | ||
</div> | ||
</div> | ||
</article> | ||
</main> | ||
<hr> | ||
${nextInteractionHtml(options)} | ||
<hr> | ||
${createFooterHtml(options)} | ||
@@ -98,12 +95,18 @@ </body> | ||
const nextInteractionHtml = (post) => { | ||
const {next, previous} = post; | ||
const {next, previous, indexed, lang} = post; | ||
let nextHtml = ``; | ||
let previousHtml = ``; | ||
if (next) { | ||
nextHtml = `Next ${linkFromPost(next)}`; | ||
nextHtml = `${translate(lang, `Next`)} ${linkFromPost(next, `rel="next"`)}`; | ||
} | ||
let previousHtml = ``; | ||
if (previous) { | ||
previousHtml = `Previous ${linkFromPost(previous)}`; | ||
previousHtml = `${translate(lang, `Previous`)} ${linkFromPost(previous, `rel="previous"`)}`; | ||
} | ||
let indexedHtml = ``; | ||
if (!indexed) { | ||
indexedHtml = `<p class="col-lg-8 col-md-10 mx-auto">Not Indexed</p>`; | ||
} | ||
return `<div class="container"><div class="row"> | ||
${indexedHtml} | ||
<p class="col-lg-8 col-md-10 mx-auto">${previousHtml}</p> | ||
@@ -110,0 +113,0 @@ <p class="col-lg-8 col-md-10 mx-auto">${nextHtml}</p> |
@@ -7,3 +7,3 @@ export {styleSheets}; | ||
<link href="/css/bootstrap-legend.css" rel="stylesheet"> | ||
<link href="/css/clean-blog.min.css" rel="stylesheet">`; | ||
<link href="/css/clean-blog.css" rel="stylesheet">`; | ||
}; |
{ | ||
"name": "blog-engine-sac", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"type": "module", | ||
@@ -46,2 +46,3 @@ "bin": { | ||
"source", | ||
"translations", | ||
"licence.txt", | ||
@@ -48,0 +49,0 @@ "README.md" |
@@ -149,2 +149,3 @@ export { processPost, supportedFormats, getDetailsFromPost }; | ||
indexed: true, | ||
ready: true, | ||
hasExternalMeta: false, | ||
@@ -151,0 +152,0 @@ externalMeta: ``, |
@@ -7,3 +7,3 @@ /* stats.birthtime, can be later than modified date | ||
import { textFileContent, writeTextInFile, namesInDirectory } from "filesac"; | ||
import { generateTags, wordCount } from "./tags.js"; | ||
import { generateTags, wordCount, setFinalTags } from "./tags.js"; | ||
import { niceDateString, normalizeDate } from "./dates.js"; | ||
@@ -161,2 +161,4 @@ import { staticCopies } from "./staticCopies.js"; | ||
defaultAuthor: undefined, | ||
mainTitle: `Blog`, | ||
subTitle: `Change title and subtitle in blog-engine-sac.json`, | ||
}; | ||
@@ -185,2 +187,7 @@ const [sourceFileNames, footerText, settingsText] = await Promise.all([ | ||
return post.src; | ||
}).filter(post => { | ||
if (!post.ready) { | ||
console.log(`\t-- ${post.title} not ready`); | ||
} | ||
return post.ready; | ||
}); | ||
@@ -194,11 +201,16 @@ | ||
posts.forEach(function (post, i) { | ||
post.next = posts[i - 1]; | ||
post.previous = posts[i + 1]; | ||
const { indexed } = post; | ||
if (indexed) { | ||
console.log(`\t++ ${post.title}`); | ||
} else { | ||
console.log(`\t+- ${post.title} not indexed`); | ||
} | ||
}); | ||
posts.forEach(function (post, i) { | ||
console.log(`\t** ${post.title} ${post.indexed ? `` : `(not indexed)` }`); | ||
}); | ||
/* | ||
const allWords = wordCount(posts); | ||
generateTags(posts, allWords); | ||
*/ | ||
setFinalTags(posts); | ||
const linkedTranslations = new Set(); | ||
@@ -210,2 +222,6 @@ const langUsed = new Set([commonOptions.defaultLang]); | ||
}); | ||
indexedPosts.forEach(function (post, i) { | ||
post.next = posts[i - 1]; | ||
post.previous = posts[i + 1]; | ||
}); | ||
indexedPosts.forEach(post => { | ||
@@ -212,0 +228,0 @@ // filter translations |
@@ -59,3 +59,3 @@ export { generateSearchCode }; | ||
treeshake: { | ||
pureExternalModules: false, | ||
moduleSideEffect: 'no-external', | ||
propertyReadSideEffects: false, // assume reading properties has no side effect | ||
@@ -62,0 +62,0 @@ }, |
@@ -27,3 +27,3 @@ export { | ||
`/../css/bootstrap-legend.css`, | ||
`/../css/clean-blog.min.css`, | ||
`/../css/clean-blog.css`, | ||
]; | ||
@@ -30,0 +30,0 @@ return copyArrayFiles(filesToCopy, { |
@@ -1,2 +0,2 @@ | ||
export { generateTags, wordCount }; | ||
export { generateTags, wordCount, setFinalTags }; | ||
@@ -35,3 +35,7 @@ | ||
} | ||
}); | ||
}; | ||
const setFinalTags = function (posts) { | ||
posts.forEach(function (post) { | ||
post.finalTags.push(...(Array.from(new Set([ | ||
@@ -38,0 +42,0 @@ ...post.tags, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
281540
30
10114
2