blog-engine-sac
Advanced tools
Comparing version 7.5.0 to 7.5.2
@@ -33,3 +33,2 @@ export { makeUrl, linkFromPost, linkFromCategory, escapeHtml, indexFileName, indexLink, categoryFileName, postStartName}; | ||
// duplicate from search | ||
const makeUrl = (ref) => { | ||
@@ -36,0 +35,0 @@ return `./${urls.posts}${ref}`; |
export { searchCodeTemplate }; | ||
// import {makeUrl} from "../html/links.js"; | ||
import {postStartName} from "../html/links.js"; | ||
import * as urls from "../defaultSettings/urls.js"; | ||
const maxResults = 10; | ||
const searchCodeTemplate = (posts) => { | ||
// todo use makeUrl | ||
const searchCodeTemplate = (posts, options) => { | ||
// todo deduplicate | ||
const {extensionLinks, defaultLang} = options; | ||
const tagsAndUrls = posts.map((post) => { | ||
const { title, searchTags, base } = post; | ||
const { title, searchTags, lang } = post; | ||
let langPrefix = ``; | ||
if (lang !== defaultLang) { | ||
langPrefix = `[${lang}] `; | ||
} | ||
return { | ||
// convert to string for lunr | ||
searchTags: searchTags.join(` `), | ||
title, | ||
url: base, | ||
title: `${langPrefix}${title}`, | ||
url: `${postStartName(post)}${extensionLinks}`, | ||
}; | ||
@@ -51,3 +57,3 @@ }); | ||
} | ||
return \`\${prePath}/${urls.posts}\${escape(ref)}\`; | ||
return \`\${prePath}/${urls.posts}\${ref}\`; | ||
}; | ||
@@ -63,3 +69,3 @@ | ||
rawResults.length = Math.min(${maxResults}, rawResults.length); // do not display more | ||
rawResults.forEach(console.log); | ||
// rawResults.forEach(console.log); | ||
const results = rawResults.map(takeRef).map(url => { | ||
@@ -66,0 +72,0 @@ return articles.find(article => { |
{ | ||
"name": "blog-engine-sac", | ||
"version": "7.5.0", | ||
"version": "7.5.2", | ||
"description": "static site generator, that uses markdown files as input and outputs web pages", | ||
@@ -26,13 +26,13 @@ "license": "CC0-1.0", | ||
"cli-sac": "^1.0.0", | ||
"filesac": "^12.0.0", | ||
"filesac": "^13.0.0", | ||
"html-escaper": "^3.0.0", | ||
"html-minifier": "^4.0.0", | ||
"lunr": "^2.3.9", | ||
"make-fetch-happen": "^8.0.10", | ||
"markdown-it": "^12.0.3", | ||
"mime-types": "^2.1.27", | ||
"make-fetch-happen": "^8.0.13", | ||
"markdown-it": "^12.0.4", | ||
"mime-types": "^2.1.28", | ||
"node-html-parser": "^1.3.1", | ||
"rollup": "^2.34.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"sharp": "^0.26.3", | ||
"sharp": "^0.27.1", | ||
"utilsac": "^14.1.0" | ||
@@ -42,3 +42,3 @@ }, | ||
"cssnano": "^4.1.10", | ||
"eslint": "^7.15.0", | ||
"eslint": "^7.19.0", | ||
"eslint-config-red": "^1.8.1", | ||
@@ -45,0 +45,0 @@ "import-postcss": "^8.0.2", |
@@ -6,3 +6,3 @@ export { postFromFileDetails, processExternalPost, supportedFormats, getDetailsFromPost, initialPost, processPostAs, getPostDefault }; | ||
import mimeTypes from "mime-types"; | ||
import { textFileContent } from "filesac"; | ||
import fsPromises from "fs/promises"; | ||
import { isLocalUrl } from "./urls.js"; | ||
@@ -33,3 +33,3 @@ import { processPostAsHTML, formatHTML } from "./processors/html.js"; | ||
post.getContent = function () { | ||
return textFileContent(fullPath); | ||
return fsPromises.readFile(fullPath, `utf-8`); | ||
}; | ||
@@ -36,0 +36,0 @@ return processPostAs(extension, post, commonOptions); |
@@ -7,7 +7,7 @@ /* stats.birthtime, can be later than modified date | ||
import { textFileContent, writeTextInFile, namesInDirectory } from "filesac"; | ||
import slugify from "@sindresorhus/slugify"; | ||
import { writeTextInFile, namesInDirectory } from "filesac"; | ||
import { chainPromises } from "utilsac"; | ||
import url from "url"; | ||
import fs from "fs"; | ||
import fsPromises from "fs/promises"; | ||
import { dirname, parse as parsePath } from "path"; | ||
@@ -126,3 +126,3 @@ import { load } from '@grossacasacs/left-phalange'; | ||
const createContact = function (commonOptions, contactSource, builtBlog) { | ||
return textFileContent(contactSource).then(function (contactMarkdown) { | ||
return fsPromises.readFile(contactSource, `utf-8`).then(function (contactMarkdown) { | ||
const contactHTMLBody = renderMarkdown(contactMarkdown); | ||
@@ -138,3 +138,3 @@ return writeTextInFile(`${builtBlog}${urls.contact}.html`, createContactHtml(Object.assign({ | ||
const createAbout = function (commonOptions, aboutSource, builtBlog) { | ||
return textFileContent(aboutSource).then(function (aboutMarkdown) { | ||
return fsPromises.readFile(aboutSource, `utf-8`).then(function (aboutMarkdown) { | ||
const aboutHTMLBody = renderMarkdown(aboutMarkdown); | ||
@@ -191,3 +191,3 @@ return writeTextInFile(`${builtBlog}${urls.about}.html`, createAboutHtml(Object.assign({ | ||
namesInDirectory(postsPath), | ||
textFileContent(footerSource), | ||
fsPromises.readFile(footerSource, `utf-8`), | ||
load(userOptionsSource), | ||
@@ -377,3 +377,3 @@ load(defaultOptionsSource), | ||
commonOptions.searchCode = await generateSearchCode(indexedPosts); | ||
commonOptions.searchCode = await generateSearchCode(indexedPosts, commonOptions); | ||
commonOptions.langUsed = langUsed; | ||
@@ -380,0 +380,0 @@ const contactPromise = createContact(commonOptions, contactSource, builtBlog); |
@@ -5,3 +5,3 @@ export { processPostAsMulti, formatMulti }; | ||
import { supportedExtensions, parse } from "@grossacasacs/left-phalange"; | ||
import {textFileContent} from "filesac"; | ||
import fsPromises from "fs/promises"; | ||
@@ -35,3 +35,3 @@ | ||
post.getContent = function () { | ||
return textFileContent(fullPath); | ||
return fsPromises.readFile(fullPath, `utf-8`); | ||
}; | ||
@@ -38,0 +38,0 @@ processPostAs(extension, post, commonOptions) |
@@ -5,5 +5,5 @@ export { generateSearchCode }; | ||
import { terser } from "rollup-plugin-terser"; | ||
import { textFileContent } from "filesac"; | ||
import path from "path"; | ||
import url from "url"; | ||
import fsPromises from "fs/promises"; | ||
@@ -74,8 +74,8 @@ | ||
const generateSearchCode = async (posts) => { | ||
codeWithImports = searchCodeTemplate(posts); | ||
const generateSearchCode = async (posts, options) => { | ||
codeWithImports = searchCodeTemplate(posts, options); | ||
try { | ||
lunrCode = await textFileContent(`${__dirname}/../node_modules/blog-engine-sac/node_modules/lunr/lunr.js`); | ||
lunrCode = await fsPromises.readFile(`${__dirname}/../node_modules/blog-engine-sac/node_modules/lunr/lunr.js`, `utf-8`); | ||
} catch (_) { | ||
lunrCode = await textFileContent(`${__dirname}/../../blog-engine-sac/node_modules/lunr/lunr.js`); | ||
lunrCode = await fsPromises.readFile(`${__dirname}/../../blog-engine-sac/node_modules/lunr/lunr.js`, `utf-8`); | ||
} | ||
@@ -82,0 +82,0 @@ lunrCode = lunrCode.replace(`}(this, function () {`, `}(window, function () {`); |
Sorry, the diff of this file is too big to display
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
538909
10918
6
+ Addedfilesac@13.0.0(transitive)
+ Addedsharp@0.27.2(transitive)
- Removedfilesac@12.1.0(transitive)
- Removedsharp@0.26.3(transitive)
Updatedfilesac@^13.0.0
Updatedmake-fetch-happen@^8.0.13
Updatedmarkdown-it@^12.0.4
Updatedmime-types@^2.1.28
Updatedsharp@^0.27.1