Socket
Socket
Sign inDemoInstall

hexo-generator-seo-friendly-sitemap

Package Overview
Dependencies
6
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.25 to 0.1.0-beta.0

views/root-page.ejs

2

index.js
'use strict';
var _ = require('lodash'),
const _ = require('lodash'),
path = require('path'),

@@ -4,0 +4,0 @@

@@ -1,10 +0,10 @@

var _ = require('lodash'),
const _ = require('lodash'),
common = require('./common')
var mentionedInPosts = function(category) {
const mentionedInPosts = function(category) {
return category.posts.length > 0
}
var category = function(locals, config) {
var get = function() {
const category = function(locals, config) {
const get = function() {
if (config.sitemap && config.sitemap.category === false) {

@@ -17,3 +17,3 @@ return

var categories = _(locals.categories.toArray())
const categories = _(locals.categories.toArray())
.filter(mentionedInPosts)

@@ -25,3 +25,3 @@ .map(common.setItemLastUpdate)

var lastUpdatedCategory = _.chain(categories)
const lastUpdatedCategory = _.chain(categories)
.first()

@@ -28,0 +28,0 @@ .get('updated')

@@ -1,12 +0,12 @@

var _ = require('lodash'),
const _ = require('lodash'),
Promise = require('bluebird'),
fs = Promise.promisifyAll(require('fs'))
var getPostUpdated = function(post) {
const getPostUpdated = function(post) {
return post.updated.toDate()
}
var common = {
const common = {
setItemLastUpdate: function(item) {
var posts = item.posts.toArray()
const posts = item.posts.toArray()
item.updated = _.maxBy(posts, getPostUpdated).updated.toDate()

@@ -13,0 +13,0 @@ return item

@@ -1,6 +0,7 @@

var Promise = require('bluebird'),
common = require('./common')
const Promise = require('bluebird'),
common = require('./common'),
_ = require('lodash')
var seoFriendlySitemap = function(locals) {
var config = this.config,
const seoFriendlySitemap = function(locals) {
const config = this.config,
posts = require('./post')(locals, config),

@@ -13,3 +14,3 @@ pages = require('./page')(locals, config),

render = require('./render')(locals, config),
sitemaps = [posts.get(), pages.get(), categories.get(), tags.get(), xsl.get()]
sitemaps = _.concat(posts.get(), pages.get(), categories.get(), tags.get(), xsl.get())

@@ -16,0 +17,0 @@ return Promise.all(sitemaps)

@@ -1,8 +0,8 @@

var _ = require('lodash'),
const _ = require('lodash'),
common = require('./common'),
urljoin = require('url-join')
var indexSitemap = function(locals, config) {
var get = function(filePaths) {
var indexSitemapItems = _.chain(filePaths)
const indexSitemap = function(locals, config) {
const get = function(filePaths) {
const indexSitemapItems = _.chain(filePaths)
.filter('isInIndexSitemap')

@@ -22,3 +22,3 @@ .map(getIndexSitemapItem)

var getIndexSitemapItem = function(item) {
const getIndexSitemapItem = function(item) {
return {

@@ -31,3 +31,3 @@ url: urljoin(config.url, item.filename),

return {
get: get
get
}

@@ -34,0 +34,0 @@ }

@@ -1,5 +0,5 @@

var _ = require('lodash')
const _ = require('lodash')
var page = function(locals, config) {
var isExcluded = function(page) {
const page = function(locals, config) {
const isExcluded = function(page) {
if (page.sitemap === false) {

@@ -14,7 +14,7 @@ return true

var get = function() {
const get = function() {
if (locals.pages.length === 0) {
return
}
var pages = _(locals.pages.toArray())
const pages = _(locals.pages.toArray())
.reject(isExcluded)

@@ -24,3 +24,3 @@ .orderBy('updated', 'desc')

var lastUpdatedPage = _.chain(pages)
const lastUpdatedPage = _.chain(pages)
.first()

@@ -27,0 +27,0 @@ .get('updated')

@@ -1,14 +0,14 @@

var _ = require('lodash')
var urljoin = require('url-join')
const _ = require('lodash')
const urljoin = require('url-join')
var postInSitemap = function(post) {
const postInSitemap = function(post) {
return post.sitemap !== false && post.published
}
var post = function(locals) {
var get = function() {
const post = function(locals, config) {
const get = function() {
if (locals.posts.length === 0) {
return
}
var posts = _(locals.posts.toArray())
const posts = _(locals.posts.toArray())
.filter(postInSitemap)

@@ -18,17 +18,39 @@ .orderBy('updated', 'desc')

var lastUpdatedPost = _.chain(posts)
.first()
.get('updated')
.value()
let sitemaps = []
if (config.sitemap.urlLimit > 0) {
const chunk = _.chunk(posts, config.sitemap.urlLimit)
sitemaps = _.map(chunk, (chunkPosts, index) => {
const lastUpdatedPost = _.chain(chunkPosts)
.first()
.get('updated')
.value()
return {
template: 'post-sitemap.ejs',
filename: `post-sitemap-${index + 1}.xml`,
data: {
items: chunkPosts,
urljoin
},
lastModification: lastUpdatedPost,
isInIndexSitemap: true
}
})
} else {
const lastUpdatedPost = _.chain(posts)
.first()
.get('updated')
.value()
sitemaps.push({
template: 'post-sitemap.ejs',
filename: 'post-sitemap.xml',
data: {
items: posts,
urljoin
},
lastModification: lastUpdatedPost,
isInIndexSitemap: true
})
}
return {
template: 'post-sitemap.ejs',
filename: 'post-sitemap.xml',
data: {
items: posts,
urljoin: urljoin
},
lastModification: lastUpdatedPost,
isInIndexSitemap: true
}
return sitemaps
}

@@ -35,0 +57,0 @@

@@ -1,2 +0,2 @@

var path = require('path'),
const path = require('path'),
Promise = require('bluebird'),

@@ -8,7 +8,7 @@ ejs = require('ejs'),

var render = function(locals, config) {
var viewPath = path.join(__dirname, '..', 'views')
const render = function(locals, config) {
const viewPath = path.join(__dirname, '..', 'views')
var getCompiledContent = function(info, templateFilePath, templateContent) {
var compiledTemplate = ejs.compile(templateContent, {
const getCompiledContent = function(info, templateFilePath, templateContent) {
const compiledTemplate = ejs.compile(templateContent, {
filename: templateFilePath

@@ -32,4 +32,4 @@ }),

var renderSitemaps = function(sitemap) {
var templateFilePath = path.join(viewPath, sitemap.template)
const renderSitemaps = function(sitemap) {
const templateFilePath = path.join(viewPath, sitemap.template)
return Promise.join(sitemap, templateFilePath, common.getFileContent(templateFilePath), getCompiledContent)

@@ -36,0 +36,0 @@ }

@@ -1,10 +0,10 @@

var _ = require('lodash'),
const _ = require('lodash'),
common = require('./common')
var mentionedInPosts = function(tag) {
const mentionedInPosts = function(tag) {
return tag.posts.length > 0
}
var tag = function(locals, config) {
var get = function() {
const tag = function(locals, config) {
const get = function() {
if (config.sitemap && config.sitemap.tag === false) {

@@ -17,3 +17,3 @@ return

var tags = _(locals.tags.toArray())
const tags = _(locals.tags.toArray())
.filter(mentionedInPosts)

@@ -25,3 +25,3 @@ .map(common.setItemLastUpdate)

var lastUpdatedTag = _.chain(tags)
const lastUpdatedTag = _.chain(tags)
.first()

@@ -28,0 +28,0 @@ .get('updated')

@@ -1,5 +0,5 @@

var common = require('./common')
const common = require('./common')
var xsl = function(locals, config) {
var get = function() {
const xsl = function(locals, config) {
const get = function() {
return {

@@ -6,0 +6,0 @@ template: 'sitemapXsl.ejs',

{
"name": "hexo-generator-seo-friendly-sitemap",
"description": "SEO-friendly sitemap generator plugin for Hexo",
"version": "0.0.25",
"version": "0.1.0-beta.0",
"author": {

@@ -13,6 +13,9 @@ "name": "Ludovic LEFEVRE",

},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"bluebird": "3.5.4",
"ejs": "2.6.1",
"lodash": "4.17.11",
"lodash": "4.17.12",
"moment": "2.24.0",

@@ -26,3 +29,3 @@ "pretty-data": "0.40.0",

"eslint-plugin-prettier": "^3.0.1",
"hexo": "^3.8.0",
"hexo": "^3.9.0",
"jest": "^24.7.1",

@@ -29,0 +32,0 @@ "normalize-newline": "3.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc