11![ npm] ( https://img.shields.io/npm/v/static-sitemap-cli )
2- ![ npm] ( https://img.shields.io/npm/dw /static-sitemap-cli )
2+ ![ npm] ( https://img.shields.io/npm/dm /static-sitemap-cli )
33
44# static-sitemap-cli
55
@@ -17,7 +17,7 @@ npm i -g static-sitemap-cli
1717
1818## Usage
1919
20- Syntax: ` static-sitemap-cli <BASEURL> < options> `
20+ Syntax: ` static-sitemap-cli <BASEURL> [ options] `
2121
2222At its simplest, just go to your ` dist ` folder and run:
2323
@@ -49,84 +49,129 @@ so that you can pipe it to do other cool stuff. CLI also allows you to pipe in B
4949| -h | --help | show CLI help |
5050| -v | --version | show CLI version |
5151| -r | --root | [ default: current dir] root directory to start from |
52- | -m | --match | [ default: ** /* .html] list of globs to match |
53- | -i | --ignore | [ default: 404.html] list of globs to ignore |
54- | -p | --priority | comma-separated glob/priority pair; eg: foo/* .html,0.1 |
55- | -f | --changefreq | comma-separated glob/changefreq pair; eg: foo/* .html,daily |
52+ | -m | --match | [ default: ** /* .html,!404.html] list of globs to match |
53+ | -p | --priority | glob-priority pair (eg: foo/* .html=0.1) |
54+ | -f | --changefreq | glob-changefreq pair (eg: foo/* .html=daily) |
5655| -n | --no-clean | disable clean URLs |
5756| -s | --slash | add trailing slash to all URLs |
57+ | -t | --text | output as .TXT instead |
58+ | -v | --verbose | be more verbose |
59+
5860
5961#### Clean URLs
6062
6163Whether or not to include the ` .html ` extension. By default, something like:
6264
63- ` https://example.com/foo/index.html ` becomes ` https://example.com/foo ` .
65+ ` rootDir/foo/index.html ` becomes ` https://example.com/foo ` .
66+
67+ ` rootDir/foo/bar/foobar.html ` becomes ` https://example.com/foo/bar/foobar ` .
6468
6569Pass ` -n ` option to disable this behavior.
6670
71+
6772#### Trailing Slashes
6873
69- Control whether or not URLs should include trailing slashes. For example:
74+ Controls whether or not URLs should include trailing slashes. For example:
7075
71- ` https://example.com /bar/index.html` becomes ` https://example.com/bar/ ` .
76+ ` rootDir /bar/index.html` becomes ` https://example.com/bar/ ` .
7277
7378For obvious reasons, this cannot be used together with ` -n ` .
7479
7580
81+ #### Ignore Some Files
82+
83+ The ` -m ` flag allows multiple entries to be input. By default it's set to the following globs: ` **/*.html ` and ` !404.html ` .
84+ You can change the glob pattern matches to suit your use-case, like:
85+
86+ ` sscli https://example.com -m '**/*.html' -m '!404.html' -m '!**/ignore/**' -m '!this/other/specific/file.html' `
87+
88+
89+ #### Glob-* Pairs
90+
91+ The ` -p ` and ` -c ` flags allow multiple entries and accept ` glob-* ` pairs as input. A ` glob-* ` pair is basically
92+ ` <glob-pattern>=<value> ` , where ` = ` separates the two. For example, a glob-frequency pair should be input as
93+ ` events/**/*.html=daily ` .
94+
95+ Entries input later will override the earlier ones. So for example in this,
96+
97+ ` sscli https://example.com -f '**/*=weekly' -f 'events/**=daily' `
98+
99+ all page entries will contain ` <changefreq>weekly</changefreq> ` while pages that match ` event/** ` will contain
100+ ` <changefreq>daily</changefreq> ` .
101+
102+
103+ #### Output as Text
104+
105+ Sitemaps can be generated in a simple [ text file] ( https://support.google.com/webmasters/answer/183668?hl=en ) format as well,
106+ where each line contains exactly one URL. Pass the option ` -t ` to do so. In this case, ` --priority ` and ` --changefreq `
107+ are redundant.
108+
109+
76110## Examples
77111
78- #### Create sitemap for ` dist/ ` folder
112+ #### Create sitemap for ` dist ` folder
79113
80- ```
81- static-sitemap-cli https://example.com -r dist/ > dist/sitemap.xml
82- ```
114+ ` static-sitemap-cli https://example.com -r dist > dist/sitemap.xml `
83115
84116OR
85117
86- ```
87- sscli https://example.com -r dist/ > dist/sitemap.xml
88- ```
118+ ` sscli https://example.com -r dist > dist/sitemap.xml `
89119
90- Note: Just put ` dist/ ` for that location, not ` dist/. ` or ` ./dist/** ` .
91120
92121#### Ignore a bunch of files
93122
94- ```
95- sscli https://example.com -i=404.html foo/**/* > sm.xml
96- ```
123+ ` sscli https://example.com -m '**/*.html' '!404.html' '!**/ignore/**' '!this/other/specific/file.html' > sm.xml `
124+
97125
98126#### Set priority of certain pages
99127
100128By default, the optional ` <priority> ` label ([ protocol reference] ( https://www.sitemaps.org/protocol.html ) ) is excluded,
101- so every pages' default is 0.5. To change the * relative* priority (to 0.1) of certain pages:
129+ so every pages' default is 0.5. To change the * relative* priority of certain pages:
130+
131+ ` sscli https://example.com -p '**/{foo,bar}/**=0.1' '**/important/**=0.9' > sm.xml `
132+
133+
134+ #### Set changefreq of all pages to weekly, and some to daily
135+
136+ ` sscli https://example.com -f '**/*=weekly' -f 'events/**=daily' > sm.xml `
102137
103- ```
104- sscli https://example.com -p=**/{foo,bar}/**,0.1 **/important/**,0.9 > sm.xml
105- ```
106138
107139#### Pipe in the base URL
108140
109- ```
110- echo https://example.com | sscli > sm.xml
111- ```
141+ ` echo https://example.com | sscli > sm.xml `
142+
112143
113144
114145## To-do
115146
116- Add tests! :sweat_smile :
147+ ~~ Add tests! :sweat_smile : ~~
148+
149+
150+ ## Tests
151+
152+ Run ` npm run test ` .
117153
118154
119155## Changelog
120156
121- ** v0.2.0 - 2019-07-31:**
157+ ** v1.0.0** - 2019-08-15:
158+ * ** BREAKING:** ` --ignore ` is deprecated. Use ` --matches ` instead.
159+ * ** BREAKING:** Glob-* pairs are no longer comma-seperated. Use ` = ` instead.
160+ * ** BREAKING:** Logic for multiple glob-* pairs changed. Later pairs override the earlier ones now.
161+ * Major refactor of original codebase; discontinued usage of [ globby] ( https://www.npmjs.com/package/globby ) and [ sitemap] ( https://www.npmjs.com/package/sitemap ) in favour of [ fast-glob] ( https://www.npmjs.com/package/fast-glob ) , [ micromatch] ( https://www.npmjs.com/package/micromatch ) , and [ js2xmlparser] ( https://www.npmjs.com/package/js2xmlparser ) .
162+ * Resulting code should be much easier to reason with and maintain now.
163+ * Add feature to output as text (one URL per line).
164+ * Add verbose mode to see some console feedback.
165+ * And finally, add tests with ~ 95% coverage.
166+
167+ ** v0.2.0** - 2019-07-31:
122168* Allow BASEURL to be piped in also.
123169* Refactor some dependencies.
124170
125- ** v0.1.1 - 2019-07-27:**
171+ ** v0.1.1** - 2019-07-27:
126172* Bugfix: properly check rootDir before replacing.
127173* Add new alias ` sscli ` because the original is quite a mouthful.
128174
129- ** v0.1.0 - 2019-07-26:**
175+ ** v0.1.0** - 2019-07-26:
130176* Initial release.
131177* Built in 10 minutes. :stuck_out_tongue_winking_eye :
132-
0 commit comments