diff --git a/lib/server/blog.js b/lib/server/blog.js index c8b4cf10ac41..0c218efc8034 100644 --- a/lib/server/blog.js +++ b/lib/server/blog.js @@ -32,7 +32,7 @@ function fileToUrl(file) { .replace(/\.md$/, '.html'); } -function getPages(numOfBlog, config) { +function getPagesMarkup(numOfBlog, config) { const BlogPageLayout = require('../core/BlogPageLayout.js'); const blogPages = {}; const perPage = 10; @@ -63,7 +63,7 @@ function getMetadata(file) { return metadata; } -function getPost(file, config) { +function getPostMarkup(file, config) { const metadata = getMetadata(file); if (!metadata) { return null; @@ -80,7 +80,7 @@ function getPost(file, config) { module.exports = { fileToUrl, getMetadata, - getPages, - getPost, + getPagesMarkup, + getPostMarkup, urlToSource, }; diff --git a/lib/server/docs.js b/lib/server/docs.js index df8e2aae4e95..e6159fb16ee2 100644 --- a/lib/server/docs.js +++ b/lib/server/docs.js @@ -83,7 +83,7 @@ function replaceAssetsLink(oldContent) { return lines.join('\n'); } -function getStr(rawContent, mdToHtml, metadata) { +function getMarkup(rawContent, mdToHtml, metadata) { // generate table of contents let content = insertTOC(rawContent); @@ -104,11 +104,8 @@ function getStr(rawContent, mdToHtml, metadata) { ); } -function getRedirectStr(metadata) { - if ( - !env.translation.enabled || - metadata.permalink.indexOf('docs/en') === -1 - ) { +function getRedirectMarkup(metadata) { + if (!env.translation.enabled || !metadata.permalink.includes('docs/en')) { return null; } const Redirect = require('../core/Redirect.js'); @@ -124,9 +121,9 @@ function getRedirectStr(metadata) { } module.exports = { - getStr, + getMarkup, getFile, - getRedirectStr, + getRedirectMarkup, mdToHtmlify, replaceAssetsLink, }; diff --git a/lib/server/generate.js b/lib/server/generate.js index d30e004ebcdf..8f4e702d7ccd 100644 --- a/lib/server/generate.js +++ b/lib/server/generate.js @@ -76,20 +76,20 @@ async function execute() { return; } const rawContent = metadataUtils.extractMetadata(file).rawContent; - const str = docs.getStr(rawContent, mdToHtml, metadata); + const str = docs.getMarkup(rawContent, mdToHtml, metadata); const targetFile = join(buildDir, metadata.permalink); writeFileAndCreateFolder(targetFile, str); // generate english page redirects when languages are enabled - const redirectStr = docs.getRedirectStr(metadata); - if (!redirectStr) { + const redirectMarkup = docs.getRedirectMarkup(metadata); + if (!redirectMarkup) { return; } const redirectFile = join( buildDir, metadata.permalink.replace('docs/en', 'docs') ); - writeFileAndCreateFolder(redirectFile, redirectStr); + writeFileAndCreateFolder(redirectFile, redirectMarkup); }); // copy docs assets if they exist @@ -120,16 +120,16 @@ async function execute() { return; } const urlPath = blog.fileToUrl(normalizedFile); - const str = blog.getPost(normalizedFile, siteConfig); - if (!str) { + const blogPost = blog.getPostMarkup(normalizedFile, siteConfig); + if (!blogPost) { return; } const targetFile = join(buildDir, 'blog', urlPath); - writeFileAndCreateFolder(targetFile, str); + writeFileAndCreateFolder(targetFile, blogPost); }); // create html files for all blog pages (collections of article previews) - const blogPages = blog.getPages(MetadataBlog.length, siteConfig); + const blogPages = blog.getPagesMarkup(MetadataBlog.length, siteConfig); Object.keys(blogPages).forEach(pagePath => { const targetFile = join(buildDir, 'blog', pagePath); writeFileAndCreateFolder(targetFile, blogPages[pagePath]); diff --git a/lib/server/server.js b/lib/server/server.js index 070c5cb1275d..7ca679f0d59d 100644 --- a/lib/server/server.js +++ b/lib/server/server.js @@ -146,8 +146,7 @@ function execute(port, options) { const rawContent = metadataUtils.extractMetadata(file).rawContent; removeModuleAndChildrenFromCache('../core/DocsLayout.js'); const mdToHtml = metadataUtils.mdToHtml(Metadata, siteConfig.baseUrl); - const str = docs.getStr(rawContent, mdToHtml, metadata); - res.send(str); + res.send(docs.getMarkup(rawContent, mdToHtml, metadata)); }); app.get(routing.sitemap(siteConfig.baseUrl), (req, res) => { @@ -180,7 +179,7 @@ function execute(port, options) { // this to regenerate on file save rather than on page request. reloadMetadataBlog(); removeModuleAndChildrenFromCache(join('..', 'core', 'BlogPageLayout.js')); - const blogPages = blog.getPages(MetadataBlog.length, siteConfig); + const blogPages = blog.getPagesMarkup(MetadataBlog.length, siteConfig); const urlPath = req.path.toString().split('blog/')[1]; if (urlPath === 'index.html') { @@ -192,7 +191,7 @@ function execute(port, options) { } else { const file = join(CWD, 'blog', blog.urlToSource(urlPath)); removeModuleAndChildrenFromCache(join('..', 'core', 'BlogPostLayout.js')); - const blogPost = blog.getPost(file, siteConfig); + const blogPost = blog.getPostMarkup(file, siteConfig); if (!blogPost) { next(); return;