Uses a docpad configuration file to specify template data that we can use in our document to generate absolute urls.
-
-
Save lucasbrigida/6482231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = | |
# ================================= | |
# Template Data | |
# These are variables that will be accessible via our templates | |
templateData: | |
# Site Information | |
site: | |
# Site Production URL | |
url: 'http://your-website.com' | |
# ----------------------------- | |
# Helpers | |
# Get the Absolute URL of a document | |
getUrl: (document) -> | |
return @site.url + (document.url or document.get?('url')) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Via helper: <a href="<%= @getUrl(@document) %>">visit me</a> | |
Without helper: <a href="<%= @[email protected] %>">visit me</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment