Last active
December 18, 2015 08:29
-
-
Save montylounge/5754082 to your computer and use it in GitHub Desktop.
Cactus plugin to place current page and directory path list in context. Most applicable for setting active nav items, breadcrumbs, etc.
This file contains hidden or 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
| def preBuildPage(site, page, context, data): | |
| """ | |
| Cactus plugin to provide current page and directory path list to template. | |
| Examples: | |
| Request: /sports/team/foo.html | |
| CURRENT_PAGE: foo.html | |
| PAGE_DIR_PATH: ['sports', 'team'] | |
| """ | |
| directory_path = page.path.split("/") | |
| current_page = directory_path.pop() | |
| context['DIRECTORY_PATH'] = directory_path | |
| context['CURRENT_PAGE'] = current_page | |
| return context, data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment