2.1.1 • Published 11 years ago

docpad-plugin-geturl v2.1.1

Weekly downloads
12
License
-
Repository
github
Last release
11 years ago

Get Url Plugin for DocPad

Take a href URL and an optional base URL and resolve them as a browser would for an anchor tag. Useful for calculating URLs relative to @site.url. See examples below.

Install (pending)

npm install --save docpad-plugin-geturl

Install for testing

git clone https://github.com/Hypercubed/docpad-plugin-geturl.git
cd docpad-plugin-geturl
npm install
make compile

Test

make test

Configuration

Requires a @site.url:

# ...
  templateData:
		site:
			url: 'http://localhost:9778'
# ...

Examples

Absolute

CallReturned
@getUrl('/')http://localhost:9778/
@getUrl('/test')http://localhost:9778/test
@getUrl('/test/')http://localhost:9778/test/
@getUrl('/test.html')http://localhost:9778/test.html

Relative

CallReturned
@getUrl('')http://localhost:9778/document.md
@getUrl('test.html')http://localhost:9778/test.html
@getUrl('../test.html')http://localhost:9778/test.html

External

CallReturned
@getUrl('//test.com')http://test.com/
@getUrl('http://test.com')http://test.com/
@getUrl('https://test.com')https://test.com/
@getUrl('test.html', 'https://test.com')https://test.com/test.html
@getUrl('../test.html', 'https://test.com/sub/')https://test.com/test.html

Objects

CallReturned
@getUrl(@document)http://localhost:9778/document.md

Arrays

CallReturned
@getUrl('/', '/test', 'test')http://localhost:9778/,http://localhost:9778/test,http://localhost:9778/test
@getBlock('styles').add(@getUrl(@site.styles)).toHTML()<link rel="stylesheet" href="http://localhost:9778/root_style.css"; /><link rel="stylesheet" href="http://localhost:9778/sub_style.css"; />

Arrays of objects

CallReturned
@getUrl(@getCollection('documents'))http://localhost:9778/sub/documents.md,http://localhost:9778/document.md

License

Licensed under the incredibly permissive MIT License Copyright © 2013+ J. Harshbarger

2.1.1

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago