GitbookIO / plugin

Sample plugin for GitBook
Apache License 2.0
66 stars 56 forks source link

How can I get page.path in Gitbook 2.0 #14

Closed saturngod closed 9 years ago

saturngod commented 9 years ago

I am using page.path in "page:after" for loading file.

At version 2.0 , we cannot use "page:after". So, I try to change with block. However, I have no idea , how to get full file path without page.path .

SamyPesse commented 9 years ago

You can use this.ctx.file.path (markdown page can acces it using {{ page.path }})

SamyPesse commented 9 years ago

The path this.ctx.file.path is relative to the book, to get an absolute path use:

path.resolve(this.book.root, this.ctx.file.path)