https://github.com/a-axton/capitalize-title
Properly capitalize article and blog titles
https://github.com/a-axton/capitalize-title
capitalize title title-case
Last synced: 3 months ago
JSON representation
Properly capitalize article and blog titles
- Host: GitHub
- URL: https://github.com/a-axton/capitalize-title
- Owner: a-axton
- License: mit
- Created: 2017-04-05T01:33:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-09-20T12:15:34.000Z (over 5 years ago)
- Last Synced: 2025-10-02T19:52:40.591Z (8 months ago)
- Topics: capitalize, title, title-case
- Language: JavaScript
- Homepage:
- Size: 340 KB
- Stars: 1
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Capitalize Title
Properly capitalize an article or blog title in Javascript. Code adapted from this post from John Resig in 2008 http://ejohn.org/blog/title-capitalization-in-javascript/.
### Rules
- Doesn't capitalize certain small words (a, an, and, as, at, but, by, en, for, if, in, of, on, or, the, to, v, via, vs)
- Doesn't change words when they have other letters than the first capitalized, eg. iTunes
- Skips words with dots, eg example.com
- First and last word of the title are always capitalized, except for the previous two rules
- A small word after a colon will be capitalized
### Installation
```
npm i capitalize-title -s
```
```
yarn add capitalize-title
```
### Usage
```js
import capitalizeTitle from 'capitalize-title';
console.log(capitalizeTitle('this is an example title'));
// > "This is an Example Title"
```
### License
MIT