|
|
@@ -74,9 +74,10 @@ async function getTemplate(templatePath) {
|
|
|
}
|
|
|
|
|
|
export async function renderTemplate({ config, meta }) {
|
|
|
+ const templateName = config.template || config.defaultTemplate
|
|
|
const templatePath =
|
|
|
config.filePath ||
|
|
|
- (await findTemplatePath(config.templateDirs, config.template))
|
|
|
+ (await findTemplatePath(config.templateDirs, templateName))
|
|
|
const fileOutputPath = config.fileOutputPath
|
|
|
const href = getHref(fileOutputPath, meta)
|
|
|
|
|
|
@@ -239,7 +240,8 @@ export async function imageToWebP({ meta, config }) {
|
|
|
}
|
|
|
|
|
|
const aspectRatio = width / height
|
|
|
- const name = config.uniqueFilenames ? base : `${base}-${generateRandomId()}`
|
|
|
+ const name = config.uniqueFilenames ? `${base}-${generateRandomId()}` : base
|
|
|
+ const outputFiles = []
|
|
|
const srcSet = await Promise.all(
|
|
|
config.imageSizes.map(async size => {
|
|
|
const sizeNum = parseInt(size.replace("w", ""), 10)
|
|
|
@@ -254,6 +256,7 @@ export async function imageToWebP({ meta, config }) {
|
|
|
.webp({ quality: config.quality })
|
|
|
.toFile(outputFile)
|
|
|
|
|
|
+ outputFiles.push(outputFile)
|
|
|
return [getCleanPath(outputFile, meta), size]
|
|
|
}),
|
|
|
)
|
|
|
@@ -261,7 +264,7 @@ export async function imageToWebP({ meta, config }) {
|
|
|
const imageRef = slugifyString(getCleanPath(path.join(filePath), meta))
|
|
|
|
|
|
return {
|
|
|
- paths: srcSet.map(src => src[0]),
|
|
|
+ paths: outputFiles,
|
|
|
detail: { srcSet, aspectRatio },
|
|
|
ref: imageRef,
|
|
|
}
|
|
|
@@ -279,7 +282,7 @@ export async function generateFavicons({ meta, config }) {
|
|
|
developerName: meta.opts.site?.author || "",
|
|
|
developerURL: meta.opts.site?.url || "",
|
|
|
dir: "auto",
|
|
|
- lang: meta.opts.site?.language | "en-US",
|
|
|
+ lang: meta.opts.site?.language || "en-US",
|
|
|
background: meta.opts.site?.backgroundColor || "#ffffff",
|
|
|
theme_color: meta.opts.site?.themeColor || "#ffffff",
|
|
|
appleStatusBarStyle: "black-translucent",
|
|
|
@@ -327,12 +330,8 @@ export async function generateFavicons({ meta, config }) {
|
|
|
htmlMeta,
|
|
|
},
|
|
|
paths: [
|
|
|
- ...response.images.map(img =>
|
|
|
- getCleanPath(path.join(fileOutputDir, img.name), meta),
|
|
|
- ),
|
|
|
- ...response.files.map(file =>
|
|
|
- getCleanPath(path.join(fileOutputDir, file.name), meta),
|
|
|
- ),
|
|
|
+ ...response.images.map(img => path.join(fileOutputDir, img.name)),
|
|
|
+ ...response.files.map(file => path.join(fileOutputDir, file.name)),
|
|
|
],
|
|
|
ref: config.name,
|
|
|
}
|
|
|
@@ -343,14 +342,16 @@ export async function generateFavicons({ meta, config }) {
|
|
|
|
|
|
export async function generateTaxonomy({ config }) {
|
|
|
const allValues = config.inputs.reduce((values, curr) => {
|
|
|
- return values.union(new Set(curr[config.indexOn]))
|
|
|
+ const items = curr[config.indexOn] || []
|
|
|
+ items.forEach(v => values.add(v))
|
|
|
+ return values
|
|
|
}, new Set())
|
|
|
const orderBy = config.orderBy || "date"
|
|
|
const sortedInputs = config.sortAscending
|
|
|
? _.sortBy(config.inputs, orderBy)
|
|
|
: _.sortBy(config.inputs, orderBy).reverse()
|
|
|
const taxonomy = config.indexOn
|
|
|
- ? allValues.values().reduce((groups, currentGroup) => {
|
|
|
+ ? [...allValues.values()].reduce((groups, currentGroup) => {
|
|
|
const grouped = {
|
|
|
...groups,
|
|
|
[currentGroup]: sortedInputs
|