hexo-breadcrumb
Advanced tools
Comparing version 1.0.4 to 1.0.5
33
index.js
@@ -13,3 +13,3 @@ /*global hexo*/ | ||
const links_li = links | ||
.map(function(link) { | ||
.map(function (link) { | ||
return `<li><a href="${link.url}"><span>${link.title}</span></a></li>`; | ||
@@ -31,3 +31,3 @@ }) | ||
function getOrderedLinksByMatrix(layout, matrix, links) { | ||
const detectedLayout = matrix.find(function(item) { | ||
const detectedLayout = matrix.find(function (item) { | ||
return item.layout === layout; | ||
@@ -37,3 +37,3 @@ }); | ||
return detectedLayout.format | ||
.map(function(key) { | ||
.map(function (key) { | ||
return links[key]; | ||
@@ -43,3 +43,8 @@ }) | ||
} | ||
/** | ||
* Setup breadcrumb | ||
* | ||
* @param {Object} data - Hexo post/page data | ||
* @return {string} breadcrumb - HTML markup for the breadcrumb | ||
*/ | ||
function setupBreadcrumb(data) { | ||
@@ -55,9 +60,9 @@ if (!breadcrumb && !breadcrumb.homepage) { | ||
title: homepage?.title || config.title, | ||
url: config.url | ||
url: config.url, | ||
}; | ||
const categoryLinks = data.categories.data.map(function(category) { | ||
const categoryLinks = data.categories.data.map(function (category) { | ||
return { | ||
title: category.name, | ||
url: category.permalink | ||
url: category.permalink, | ||
}; | ||
@@ -68,3 +73,3 @@ }); | ||
title: data?.title || data.slug, | ||
url: data.permalink | ||
url: data.permalink, | ||
}; | ||
@@ -75,3 +80,3 @@ | ||
category: categoryLinks, | ||
title: titleLink | ||
title: titleLink, | ||
}; | ||
@@ -81,10 +86,10 @@ | ||
console.log({ links }); | ||
return toHTML(links); | ||
} | ||
// Register before_post_render filter | ||
// Ref: https://hexo.io/api/filter#before-post-render | ||
hexo.extend.filter.register("before_post_render", function(data) { | ||
/* | ||
* Register before_post_render filter | ||
* Ref: https://hexo.io/api/filter#before-post-render | ||
*/ | ||
hexo.extend.filter.register("before_post_render", function (data) { | ||
if (data.layout !== "post" && data.layout !== "page") { | ||
@@ -91,0 +96,0 @@ return data; |
{ | ||
"name": "hexo-breadcrumb", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Generate breadcrumb for a Hexo page", | ||
@@ -34,4 +34,4 @@ "main": "index.js", | ||
"eslint": "^8.42.0", | ||
"prettier": "^1.19.1" | ||
"prettier": "^2.8.8" | ||
} | ||
} |
@@ -50,3 +50,3 @@ # hexo-breadcrumb | ||
```ejs | ||
<%- post.breadcrumb.html %> | ||
<%- post.breadcrumb %> | ||
``` | ||
@@ -57,3 +57,3 @@ | ||
```ejs | ||
<%- page.breadcrumb.html %> | ||
<%- page.breadcrumb %> | ||
``` | ||
@@ -60,0 +60,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6195
79