Skip to content

Commit

Permalink
fix: config object in events
Browse files Browse the repository at this point in the history
ensure `page` object exists
  • Loading branch information
cossssmin committed Aug 27, 2024
1 parent 0ed2ee2 commit e3a4b36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/generators/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export async function render(html = '', config = {}) {
})) ?? content
}

// Compile PostHTML
/**
* Compile PostHTML
*/
const compiled = await compilePostHTML(content, templateConfig)

/**
Expand All @@ -86,11 +88,10 @@ export async function render(html = '', config = {}) {
compiled.html = await templateConfig.afterRender(({
html: compiled.html,
matter: matterData,
config: templateConfig,
config: compiled.config,
})) ?? compiled.html
}

// Run Transformers
/**
* Run Transformers
*
Expand All @@ -101,10 +102,9 @@ export async function render(html = '', config = {}) {
* @returns {string} - The transformed HTML
*/
if (templateConfig.useTransformers !== false) {
compiled.html = await useTransformers(compiled.html, templateConfig).then(({ html }) => html)
compiled.html = await useTransformers(compiled.html, compiled.config).then(({ html }) => html)
}

// Run `afterTransformers` event
/**
* Run `afterTransformers` event
*
Expand All @@ -118,12 +118,12 @@ export async function render(html = '', config = {}) {
compiled.html = await templateConfig.afterTransformers(({
html: compiled.html,
matter: matterData,
config: templateConfig,
config: compiled.config,
})) ?? compiled.html
}

return {
config: templateConfig,
config: compiled.config,
html: compiled.html,
}
}
2 changes: 1 addition & 1 deletion src/posthtml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function process(html = '', config = {}) {
])
.process(html, posthtmlOptions)
.then(result => ({
config,
config: merge(config, { page: config }),
html: result.html,
}))
.catch(error => {
Expand Down

0 comments on commit e3a4b36

Please sign in to comment.