Skip to content

Commit

Permalink
merge and bump
Browse files Browse the repository at this point in the history
  • Loading branch information
counterbeing committed Jan 7, 2015
2 parents 759584f + 1c1a04e commit 0a076ea
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,31 @@ Set this to override `<changefreq>` in sitemap.

Set this to override `<priority>` in sitemap.

#### extension

* Type: `object`
* Default: `{ required: true }`

Eg.

````javascript
extension: {
required: false
}
````

and if you need to trailing slash simply add the attribute `trailingSlash: true` Eg.

````javascript
extension: {
required: false
trailingSlash: true
}
````

By default the `<loc>` is generated with a path that contains extension.
Eg: '.hmlt' or '.htm'.
To make your path without extension just add `extension: { required: false }` for this **required** of extension attribute.

## Contributing
We accept pull requests! A special thanks to XhmikosR for keeping things rolling.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-sitemap",
"description": "Grunt sitemap generator plugin",
"version": "1.2.0",
"version": "1.2.1",
"homepage": "https://github.com/RayViljoen/grunt-sitemap",
"author": {
"name": "Ray Viljoen",
Expand Down
17 changes: 15 additions & 2 deletions src/sitemap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Licensed under the MIT license.

module.exports = (grunt) ->

# Node modules
path = require 'path'
fs = require 'fs'
Expand Down Expand Up @@ -43,6 +42,9 @@ module.exports = (grunt) ->
# changereq setting
changefreq = @data.changefreq or 'daily'

# extension setting
extension = if @data.extension? then @data.extension else { required: true }

# priority setting
# Must be string
priority = (@data.priority or 0.5).toString()
Expand Down Expand Up @@ -73,7 +75,18 @@ module.exports = (grunt) ->
if rawUrlPath.indexOf('/') is 0 then rawUrlPath = rawUrlPath.replace '/', ''

# Remove index.html
urlPath = rawUrlPath.replace /(index)\.[A-z]+$/, '', 'i'
rawUrlPath = rawUrlPath.replace /(index)\.[A-z]+$/, '', 'i'

urlPath = switch
when typeof(extension) == 'object' && !extension.required && extension.trailingSlash
# Remove extension with trailing slash
rawUrlPath.replace /\.html/, '/', 'i'
when typeof(extension) == 'object' && !extension.required && !extension.trailingSlash
# Remove extension without trailing slash
rawUrlPath.replace /\.html/, '', 'i'
else
# only return path with extension
rawUrlPath

# Join path with homepage url
fileStat.url = url + urlPath
Expand Down
19 changes: 16 additions & 3 deletions tasks/sitemap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0a076ea

Please sign in to comment.