Skip to content

Commit

Permalink
Merge pull request #32 from ulkajs/0.6.4
Browse files Browse the repository at this point in the history
0.6.4
  • Loading branch information
coderosh-zz authored Oct 20, 2020
2 parents a80e360 + 6c1c48d commit b5ff754
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
.prettierrc
.prettierignore
.eslintignore
.gitattributes
.eslintrc.json
jsconfig.json
jest.config.js
.huskyrc.json
CODE_OF_CONDUCT.md
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.6.4

- Removed cache from ulka render
- Allow plugin to add renderer to info.

## v0.6.3

- Bug fix for async plugins
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ulka",
"version": "0.6.4-rc.2",
"version": "0.6.4",
"description": "Ulka - A simpler static site generator written in JavaScript",
"main": "./src/index.js",
"bin": {
Expand Down
36 changes: 28 additions & 8 deletions src/utils/build-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,22 @@ async function contentToHtml(contentData, contents, info) {
}
}

const html = renderUlka(
contentData.template,
context,
contentData.templatePath || filePath,
info
)
const ext = path.parse(contentData.templatePath || "").ext

const useUlka =
ext === "" || ext === ".ulka" || typeof info.renderer[ext] !== "function"

let html = ""
if (useUlka) {
html = renderUlka(
contentData.template,
context,
contentData.templatePath || filePath,
info
)
} else {
html = info.renderer[ext](contentData.template, context, info)
}

mkdir(path.parse(contentData.buildPath).dir)

Expand Down Expand Up @@ -336,7 +346,16 @@ async function pageToHtml(pageData, pages, contents, info) {
if (pageData.type === "raw") {
const context = { ...pageData, contents, pages, info }
const filePath = pageData.source || info.cwd
pageData.html = renderUlka(pageData.content, context, filePath, info)

const ext = path.parse(filePath).ext

const extRenderer = info.renderer[ext]

if (ext === "" || ext === ".ulka" || typeof extRenderer !== "function") {
pageData.html = renderUlka(pageData.content, context, filePath, info)
} else {
pageData.html = extRenderer(pageData.content, context, info)
}
} else {
pageData.html = pageData.content
}
Expand Down Expand Up @@ -373,7 +392,8 @@ function createInfo(cwd, task) {
return {
configs: getConfigs(cwd),
cwd,
task
task,
renderer: {}
}
} catch (e) {
log.error(e.message, true)
Expand Down

0 comments on commit b5ff754

Please sign in to comment.