Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Add themeable url function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Eldh committed Feb 27, 2015
1 parent 180faf8 commit 1b4ec3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion paths.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _ = require 'lodash'
markdown = require 'commonmark'
mdReader = new markdown.Parser()
mdWriter = new markdown.HtmlRenderer()
themeFunctions = require './theme/functions'

module.exports =

Expand All @@ -17,7 +18,7 @@ module.exports =
# console.log name, file
fileName = name.slice 2 # Remove the "./"

url = _.kebabCase fileName.slice 11, fileName.length - 3 #Clean the filename to get the url
url = themeFunctions?.url?(file, fileName) or fileName.slice 0, fileName.length - 3 #Clean the filename to get the url
date = file.date or fileName.slice 0, 10 # Get the date from the file name if it's not in the frontmatter

content = mdWriter.render mdReader.parse file.__content
Expand Down
5 changes: 5 additions & 0 deletions theme/functions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_ = require 'lodash'

module.exports =
url: (file, fileName) ->
_.kebabCase fileName.slice 11, fileName.length - 3 #Clean the filename to get the url

0 comments on commit 1b4ec3f

Please sign in to comment.