Skip to content

Commit

Permalink
Fixed default pages generation (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Mar 30, 2021
1 parent 6bf237e commit 7290e75
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions scripts/lib/generators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const chalk = require('chalk')

module.exports = function (hexo) {
let apiData = []
const defaultPages = ['Tags', 'Archives']

// Remove hexo default generators
// ;['post', 'page', 'archive', 'category', 'tag'].forEach(
Expand All @@ -35,15 +36,37 @@ module.exports = function (hexo) {

hexo.extend.generator.register('obsidianext-page', function (site) {
const pageData = []
const themeConfig = hexo.theme.config

// Generating default pages
defaultPages.forEach(function (page) {
if (themeConfig.menu[page]) {
pageData.push({
path: `${page.toLocaleLowerCase()}/index.html`,
data: {},
layout: ['index']
})
}
})

site.pages.forEach(function (page) {
pageData.push({
path: `page/${page.path}`,
data: {},
layout: ['index']
})
// About page need to be generated to the root of `public` folder.
if (page.type === 'about') {
pageData.push({
path: page.path,
data: {},
layout: ['index']
})
} else {
// All other custom pages are generated into `page` folder.
pageData.push({
path: `page/${page.path}`,
data: {},
layout: ['index']
})
}
})

// Generate the page for tag search.
pageData.push({
path: 'tags/search/index.html',
data: {},
Expand Down

0 comments on commit 7290e75

Please sign in to comment.