{"id":27339423,"url":"https://github.com/bxt/nav_links","last_synced_at":"2025-04-12T15:53:37.378Z","repository":{"id":10706876,"uuid":"12953316","full_name":"bxt/nav_links","owner":"bxt","description":"Rails helper to generate navigation links with a selected class.","archived":false,"fork":false,"pushed_at":"2022-10-19T19:23:20.000Z","size":31,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-10T22:16:42.553Z","etag":null,"topics":["gem","nav-links","rails","rails-helper","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bxt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-19T16:23:27.000Z","updated_at":"2018-08-15T21:26:28.000Z","dependencies_parsed_at":"2022-09-02T06:03:24.926Z","dependency_job_id":null,"html_url":"https://github.com/bxt/nav_links","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxt%2Fnav_links","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxt%2Fnav_links/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxt%2Fnav_links/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bxt%2Fnav_links/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bxt","download_url":"https://codeload.github.com/bxt/nav_links/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465311,"owners_count":21108243,"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":["gem","nav-links","rails","rails-helper","ruby"],"created_at":"2025-04-12T15:53:36.366Z","updated_at":"2025-04-12T15:53:37.373Z","avatar_url":"https://github.com/bxt.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Behold, the NavLinks:\n\n[![Build Status](https://travis-ci.org/bxt/wptemplates.png?branch=master)](https://travis-ci.org/bxt/wptemplates)\n[![Gem Version](https://badge.fury.io/rb/nav_links.png)](http://badge.fury.io/rb/nav_links)\n\nGem. Rails. Nav links. The nav_link_to helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link. Just replace `link_to` with `nav_link_to` in your templates.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'nav_links'\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\nThe `nav_link_to` helper is used just like the good old `link_to` rails helper:\n\n    \u003c%= nav_link_to 'My Page', my_path %\u003e\n\nWhen `my_path` is the same as the current page url, this outputs:\n\n    \u003ca class=\"selected\" href=\"http://example.com/page\"\u003eMy Page\u003c/a\u003e\n\nFor more options and full usage details, see: http://viget.com/extend/rails-selected-nav-link-helper\n\n### Usage with blocks:\n\nSame usage as `link_to`:\n\n    \u003c%= nav_link_to 'http://example.com/page' do %\u003e\n      \u003cstrong\u003eMy Page\u003c/strong\u003e\n    \u003c% end %\u003e\n\n### Group links with same options\n\nYou can reduce duplication and wrap `nav_link_to` calls with the same options with a call to `nav_links` like this:\n\n    \u003cul class=\"nav\"\u003e\n      \u003c% nav_links url_segment: 1, wrapper: 'li', selected_class:'active' do |nav| %\u003e\n        \u003c%= nav.link_to \"Projects\", projects_path %\u003e\n        \u003c%= nav.link_to \"People\", people_path %\u003e\n        \u003c%= nav.link_to \"About\", about_path %\u003e\n      \u003c% end %\u003e\n    \u003c/ul\u003e\n\n## Rainy day?\n\nHere's what you can do on a rainy day:\n\n  - Write integration tests\n  - Extend docs\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Credits\n\nThis gem is mostly based on the gem [nav_lynx](https://github.com/vigetlabs/nav_lynx) and sponsored by [Sophisticates GmbH](http://sophisticates.de/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbxt%2Fnav_links","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbxt%2Fnav_links","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbxt%2Fnav_links/lists"}