Skip to content

Commit 76d044c

Browse files
committed
Add repo link
1 parent 7643307 commit 76d044c

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

Readme.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,20 @@ gem "js-routes"
1616

1717
There are several possible ways to setup JsRoutes:
1818

19-
* [Quick and easy](#quick-start) - Recommended
19+
1. [Quick and easy](#quick-start) - Recommended
2020
* Uses Rack Middleware to automatically update routes locally
2121
* Automatically generates routes files on javascript build
2222
* Works great for a simple Rails application
23-
* [Advanced Setup](#advanced-setup)
23+
1. [Advanced Setup](#advanced-setup)
2424
* Allows very custom setups
2525
* Automatic updates need to be customized
26-
* [Webpacker ERB Loader](#webpacker) - Legacy
26+
1. [Webpacker ERB Loader](#webpacker) - Legacy
2727
* Requires ESM module system (the default)
2828
* Doesn't support typescript definitions
29-
* [Sprockets](#sprockets) - Legacy
29+
1. [Sprockets](#sprockets) - Legacy
3030
* Deprecated and not recommended for modern apps
3131

32-
<div id='quick-start'></div>
33-
34-
### Quick Start
32+
### Quick Start {#quick-start}
3533

3634
Setup [Rack Middleware](https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack)
3735
to automatically generate and maintain `routes.js` file and corresponding
@@ -77,13 +75,10 @@ Add js-routes files to `.gitignore`:
7775
/app/javascript/routes.d.ts
7876
```
7977

80-
<div id='webpacker'></div>
81-
82-
### Webpacker ERB loader
78+
### Webpacker ERB loader {#webpack}
8379

8480
**IMPORTANT**: the setup doesn't support IDE autocompletion with [Typescript](https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html)
8581

86-
8782
#### Use a Generator
8883

8984
Run a command:
@@ -133,24 +128,22 @@ Create routes file `app/javascript/routes.js.erb`:
133128
<%= JsRoutes.generate() %>
134129
```
135130

136-
Use routes wherever you need them:
131+
Use routes wherever you need them:
137132

138133
``` javascript
139134
import {post_path} from 'routes.js.erb';
140135

141136
alert(post_path(2));
142137
```
143138

144-
<div id='advanced-setup'></div>
145-
146-
### Advanced Setup
139+
### Advanced Setup {#advanced-setup}
147140

148141
**IMPORTANT**: that this setup requires the JS routes file to be updates manually
149142

150143
Routes file can be generated with a `rake` task:
151144

152145
``` sh
153-
rake js:routes
146+
rake js:routes
154147
# OR for typescript support
155148
rake js:routes:typescript
156149
```
@@ -192,11 +185,9 @@ JsRoutes.generate!(
192185
)
193186
```
194187

195-
<div id='definitions'></div>
196-
197-
#### Typescript Definitions
188+
#### Typescript Definitions {#definitions}
198189

199-
JsRoutes has typescript support out of the box.
190+
JsRoutes has typescript support out of the box.
200191

201192
Restrictions:
202193

@@ -208,16 +199,14 @@ More advanced setup would involve calling manually:
208199

209200
``` ruby
210201
JsRoutes.definitions! # to output to file
211-
# or
202+
# or
212203
JsRoutes.definitions # to output to string
213204
```
214205

215206
Even more advanced setups can be achieved by setting `module_type` to `DTS` inside [configuration](#module_type)
216207
which will cause any `JsRoutes` instance to generate defintions instead of routes themselves.
217208

218-
<div id="sprockets"></div>
219-
220-
### Sprockets (Deprecated)
209+
### Sprockets (Deprecated) {#sprockets}
221210

222211
If you are using [Sprockets](https://github.com/rails/sprockets-rails) you may configure js-routes in the following way.
223212

js-routes.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
2222
s.licenses = ["MIT"]
2323
s.require_paths = ["lib"]
2424
s.summary = %q{Brings Rails named routes to javascript}
25+
s.metadata = { "github_repo" => "ssh://github.com/railsware/js-routes" }
2526

2627
s.add_runtime_dependency(%q<railties>, [">= 4"])
2728
s.add_runtime_dependency(%q<sorbet-runtime>)

0 commit comments

Comments
 (0)