{"id":18434699,"url":"https://github.com/assemble/assemble-middleware-page-variable","last_synced_at":"2025-04-07T19:31:53.216Z","repository":{"id":57184963,"uuid":"78160793","full_name":"assemble/assemble-middleware-page-variable","owner":"assemble","description":"Assemble middleware for adding a `page` variable to the context, with details about the current item being rendered.","archived":false,"fork":false,"pushed_at":"2017-01-06T00:56:26.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-23T00:05:07.263Z","etag":null,"topics":["assemble","middleware","page","variable"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/assemble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-06T00:55:44.000Z","updated_at":"2017-08-16T20:24:13.000Z","dependencies_parsed_at":"2022-09-14T09:01:15.171Z","dependency_job_id":null,"html_url":"https://github.com/assemble/assemble-middleware-page-variable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-middleware-page-variable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-middleware-page-variable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-middleware-page-variable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-middleware-page-variable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/assemble","download_url":"https://codeload.github.com/assemble/assemble-middleware-page-variable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247716351,"owners_count":20984225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assemble","middleware","page","variable"],"created_at":"2024-11-06T06:04:58.753Z","updated_at":"2025-04-07T19:31:52.851Z","avatar_url":"https://github.com/assemble.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# assemble-middleware-page-variable [![NPM version](https://img.shields.io/npm/v/assemble-middleware-page-variable.svg?style=flat)](https://www.npmjs.com/package/assemble-middleware-page-variable) [![NPM monthly downloads](https://img.shields.io/npm/dm/assemble-middleware-page-variable.svg?style=flat)](https://npmjs.org/package/assemble-middleware-page-variable)  [![NPM total downloads](https://img.shields.io/npm/dt/assemble-middleware-page-variable.svg?style=flat)](https://npmjs.org/package/assemble-middleware-page-variable) [![Linux Build Status](https://img.shields.io/travis/assemble/assemble-middleware-page-variable.svg?style=flat\u0026label=Travis)](https://travis-ci.org/assemble/assemble-middleware-page-variable)\n\n\u003e Assemble middleware for adding a `page` variable to the context, with details about the current item being rendered.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save assemble-middleware-page-variable\n```\n\n## Usage\n\nThis middleware will work with [assemble](https://github.com/assemble/assemble), [verb](https://github.com/verbose/verb), [generate](https://github.com/generate/generate), [update](https://github.com/update/update) or any other node.js application based on the [templates](https://github.com/jonschlinkert/templates) library.\n\n```js\nvar pageData = require('assemble-middleware-page-variable');\nvar assemble = require('assemble');\nvar app = assemble();\n\napp.onLoad(/\\.md$/, pageData(app));\nvar page = app.page('home.md', {\n  contents: new Buffer('---\\ntitle: Home\\n---\\n\\nThis is {{page.title}}')\n});\n\napp.render(page, function(err, view) {\n  if (err) return console.log(err);\n  console.log(view.contents.toString());\n  //=\u003e 'This is Home'\n});\n```\n\nThen, inside templates you can use the variable like this:\n\n```handlebars\n---\ntitle: Home\n---\n\nThis is the {{page.title}} page.\n```\n\nWhich would render to:\n\n```html\nThis is the Home page.\n```\n\n## Custom variable\n\nOptionally specify a custom property name to use instead of `page`.\n\n```js\n// you don't need to create a custom collection too, this is just an example\napp.create('posts');\napp.onLoad(/\\.md$/, pageData(app, 'post'));\n\nvar post = app.post('home.md', {\n  contents: new Buffer('---\\ntitle: Home\\n---\\n\\nThis is {{post.title}}')\n});\n\napp.render(post, function(err, view) {\n  if (err) return console.log(err);\n  console.log(view.contents.toString());\n  //=\u003e 'This is Home'\n});\n```\n\n## About\n\n### Related projects\n\n* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble \"Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit\")\n* [generate](https://www.npmjs.com/package/generate): Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… [more](https://github.com/generate/generate) | [homepage](https://github.com/generate/generate \"Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the robustness and configurability of Yeoman, the expressiveness and simplicity of Slush, and more powerful flow control and composability than either.\")\n* [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine… [more](https://github.com/jonschlinkert/templates) | [homepage](https://github.com/jonschlinkert/templates \"System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.\")\n* [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update \"Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.\")\n* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb \"Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for avice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_\n\nTo generate the readme and API documentation with [verb](https://github.com/verbose/verb):\n\n```sh\n$ npm install -g verb verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT license](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.3, on January 05, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemble%2Fassemble-middleware-page-variable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassemble%2Fassemble-middleware-page-variable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemble%2Fassemble-middleware-page-variable/lists"}