Skip to content

Commit

Permalink
perf: optimize the page path judgment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed Nov 30, 2023
1 parent 2b0c227 commit 2437a13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
6 changes: 3 additions & 3 deletions layout/_partial/scripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
<% } %>
<!-- category-page -->
<% if (isCategoriesPage(page.path) === true) { %>
<% if (is_current('/categories') || is_current('/category')) { %>
<%- __js('js/page/category-page.js') %>
<% } %>
<!-- links-page -->
<% if (isLinksPage(page.path) === true) { %>
<% if (is_current('/links') || is_current('/link')) { %>
<%- __js('js/page/links-page.js') %>
<% } %>
<!-- photos-page -->
<% if (isPhotosPage(page.path) === true) { %>
<% if (is_current('/photos') || is_current('/photo')) { %>
<%- __js('js/page/photos-page.js') %>
<% } %>
</div>
Expand Down
12 changes: 0 additions & 12 deletions scripts/helpers/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,3 @@ hexo.extend.helper.register('isJsFile', function (path) {
hexo.extend.helper.register('isCssFile', function (path) {
return /\.css$/i.test(path)
})

hexo.extend.helper.register('isLinksPage', function (pagePath) {
return pagePath === 'links/index.html'
})

hexo.extend.helper.register('isPhotosPage', function (pagePath) {
return pagePath === 'photos/index.html'
})

hexo.extend.helper.register('isCategoriesPage', function (pagePath) {
return pagePath === 'categories/index.html'
})

0 comments on commit 2437a13

Please sign in to comment.