Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 40 additions & 36 deletions src/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,6 @@ const TEMP_DROPDOWN_PLACEHOLDER_CLASS = 'temp-dropdown-placeholder';
cheerio.prototype.options.xmlMode = true; // Enable xml mode for self-closing tag
cheerio.prototype.options.decodeEntities = false; // Don't escape HTML entities

function Page(pageConfig) {
this.asset = pageConfig.asset;
this.baseUrl = pageConfig.baseUrl;
this.baseUrlMap = pageConfig.baseUrlMap;
this.content = pageConfig.content || '';
this.faviconUrl = pageConfig.faviconUrl;
this.layout = pageConfig.layout;
this.layoutsAssetPath = pageConfig.layoutsAssetPath;
this.rootPath = pageConfig.rootPath;
this.enableSearch = pageConfig.enableSearch;
this.plugins = pageConfig.plugins;
this.pluginsContext = pageConfig.pluginsContext;
this.searchable = pageConfig.searchable;
this.src = pageConfig.src;
this.template = pageConfig.pageTemplate;
this.title = pageConfig.title || '';
this.titlePrefix = pageConfig.titlePrefix;
this.userDefinedVariablesMap = pageConfig.userDefinedVariablesMap;

// the source file for rendering this page
this.sourcePath = pageConfig.sourcePath;
// the temp path for writing intermediate result
this.tempPath = pageConfig.tempPath;
// the output path of this page
this.resultPath = pageConfig.resultPath;

this.frontMatter = {};
this.headFileBottomContent = '';
this.headFileTopContent = '';
this.headings = {};
this.headingIndexingLevel = pageConfig.headingIndexingLevel;
this.includedFiles = {};
this.keywords = {};
this.navigableHeadings = {};
}

/**
* Util Methods
*/
Expand Down Expand Up @@ -206,6 +170,46 @@ function formatSiteNav(renderedSiteNav, src) {
return $.html();
}

function Page(pageConfig) {

@jamos-tay jamos-tay Mar 19, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to move this down for eslint because it references calculateNewBaseUrl, only lines 208-210 are added

this.asset = pageConfig.asset;
this.baseUrl = pageConfig.baseUrl;
this.baseUrlMap = pageConfig.baseUrlMap;
this.content = pageConfig.content || '';
this.faviconUrl = pageConfig.faviconUrl;
this.layout = pageConfig.layout;
this.layoutsAssetPath = pageConfig.layoutsAssetPath;
this.rootPath = pageConfig.rootPath;
this.enableSearch = pageConfig.enableSearch;
this.plugins = pageConfig.plugins;
this.pluginsContext = pageConfig.pluginsContext;
this.searchable = pageConfig.searchable;
this.src = pageConfig.src;
this.template = pageConfig.pageTemplate;
this.title = pageConfig.title || '';
this.titlePrefix = pageConfig.titlePrefix;
this.userDefinedVariablesMap = pageConfig.userDefinedVariablesMap;

// the source file for rendering this page
this.sourcePath = pageConfig.sourcePath;
// the temp path for writing intermediate result
this.tempPath = pageConfig.tempPath;
// the output path of this page
this.resultPath = pageConfig.resultPath;

this.frontMatter = {};
this.headFileBottomContent = '';
this.headFileTopContent = '';
this.headings = {};
this.headingIndexingLevel = pageConfig.headingIndexingLevel;
this.includedFiles = {};
this.keywords = {};
this.navigableHeadings = {};

const newBaseUrl = calculateNewBaseUrl(this.sourcePath, this.rootPath, this.baseUrlMap);
const configUrl = newBaseUrl ? path.join(this.rootPath, newBaseUrl) : this.rootPath;
nunjucks.configure(configUrl);
}

/**
* Generates a heading selector based on the indexing level
* @param headingIndexingLevel to generate
Expand Down
2 changes: 2 additions & 0 deletions src/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ function Site(rootPath, outputPath, onePagePath, forceReload = false, siteConfig
this.siteConfig = {};
this.siteConfigPath = siteConfigPath;
this.userDefinedVariablesMap = {};

nunjucks.configure(this.rootPath);
}

/**
Expand Down