Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kentcdodds/netlify-shortener
Your own free URL shortener with Netlify
https://github.com/kentcdodds/netlify-shortener
Last synced: 22 days ago
JSON representation
Your own free URL shortener with Netlify
- Host: GitHub
- URL: https://github.com/kentcdodds/netlify-shortener
- Owner: kentcdodds
- License: mit
- Created: 2018-12-07T06:09:57.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2021-05-27T02:52:39.000Z (over 3 years ago)
- Last Synced: 2024-10-03T00:13:14.963Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.youtube.com/watch?v=HL6paXyx6hM&list=PLV5CVI1eNcJgCrPH_e6d57KRUTiDZgs0u
- Size: 69.3 KB
- Stars: 791
- Watchers: 8
- Forks: 77
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-list - netlify-shortener
README
netlify-shortener
Uses netlify's redirect functionality to make a personal URL shortener. Works beautifully :)
---
[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
[![version][version-badge]][package]
[![downloads][downloads-badge]][npmtrends]
[![MIT License][license-badge]][license]
[![All Contributors][all-contributors-badge]](#contributors-)
[![PRs Welcome][prs-badge]][prs]
[![Code of Conduct][coc-badge]][coc]## The problem
You want a URL shortener for your custom domain and you want an easy way to
create and update URLs but you don't want to pay hundreds of dollars a year.## This solution
This relies on [Netlify's](https://www.netlify.com)
[`_redirects`](https://www.netlify.com/docs/redirects/) file for building a
super simple URL shortener where the URLs are managed on GitHub and Netlify
handles the redirecting for you.## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Shell Function](#shell-function)
- [Shell Agnostic](#shell-agnostic)
- [Bash](#bash)
- [Inspiration](#inspiration)
- [Other Solutions](#other-solutions)
- [Issues](#issues)
- [π Bugs](#-bugs)
- [π‘ Feature Requests](#-feature-requests)
- [Contributors β¨](#contributors-)
- [LICENSE](#license)## Installation
This module is distributed via [npm][npm] which is bundled with [node][node] and
should be installed as one of your project's `dependencies`:```
npm install --save netlify-shortener
```## Usage
- [Watch a demo](https://www.youtube.com/watch?v=HL6paXyx6hM&list=PLV5CVI1eNcJgCrPH_e6d57KRUTiDZgs0u)
- [View the example repo](https://github.com/kentcdodds/netlify-shortener-example)Your project should have a `_redirects` file that looks like this:
```
/example http://example.com# fallback
/* https://your-website.com
```This module exposes a binary that you should use in your `package.json` scripts.
You also need to add a `homepage` to your `package.json`:```json
{
"homepage": "https://jsair.io",
"scripts": {
"shorten": "netlify-shortener"
}
}
```Then you can run:
```
npm run shorten # simply formats your _redirects file
npm run shorten https://yahoo.com # generates a short code and adds it for you
npm run shorten https://github.com gh # adds gh as a short URL for you
```The `netlify-shortener` does a few things:
1. generates a short code if one is not provided
2. validates your URL is a real URL
3. adds the URL to the top of `_redirects`
4. runs a git commit and push (this will trigger netlify to deploy your new
redirect)
5. Copies the short URL to your clipboardNetlify's deploys are normally fast enough that the new URL should be deployed
by the time you've shared it to someone.## Shell Function
If you want to be able to run this anywhere in the terminal, you can try making
a custom function for your shell.### Shell Agnostic
1. Add the following [executable definition][npm-bin] to your `package.json`:
```json
{"bin": {"shorten": "cli.js"}}
```
2. Create the `cli.js` file:
```js
#!/usr/bin/env node
require('netlify-shortener')
```
3. From your project directory, run the following to register the command
globally:
```sh
npm link
```## ScriptKit
You can use [this script](https://github.com/johnlindquist/kit/discussions/295#discussion-3383989)
with [ScriptKit](https://www.scriptkit.com/) which integrates with netlify-shortener as well.## Inspiration
URL shorteners for custom domains and custom short codes are insanely expensive.
Hiveam.com was the best price-wise, but the price went up and it's super
expensive as well.## Other Solutions
- [netlify-shortener-sh](https://github.com/caarlos0/netlify-shortener-sh):
plain shell script versionIf you know more alternatives, please [make a pull request][prs] and add it
here!## Issues
_Looking to contribute? Look for the [Good First Issue][good-first-issue]
label._### π Bugs
Please file an issue for bugs, missing documentation, or unexpected behavior.
[**See Bugs**][bugs]
### π‘ Feature Requests
Please file an issue to suggest new features. Vote on feature requests by adding
a π. This helps maintainers prioritize what to work on.[**See Feature Requests**][requests]
## Contributors β¨
Thanks goes to these people ([emoji key][emojis]):
Kent C. Dodds
π» π π β οΈ
Carl Rosell
π€
Phil Hawksworth
π€
Matt Ferderer
π
Jed Fox
π‘
Eric McCormick
π
Preston Lamb
π»
Daniel D. Beck
π
Justin Dorfman
π
Jake Jarvis
π»
MichaΓ«l De Boey
π»
OisΓn Quinn
π» β οΈ
SebJones
π»
Gabin Aureche
π» β οΈ
Anton Andreasson
π»
Marcus Lyons
π
This project follows the [all-contributors][all-contributors] specification.
Contributions of any kind welcome!## LICENSE
MIT
[npm]: https://www.npmjs.com
[node]: https://nodejs.org
[build-badge]: https://img.shields.io/github/workflow/status/kentcdodds/netlify-shortener/validate?logo=github&style=flat-square
[build]: https://github.com/kentcdodds/netlify-shortener/actions?query=workflow%3Avalidate
[coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/netlify-shortener.svg?style=flat-square
[coverage]: https://codecov.io/github/kentcdodds/netlify-shortener
[version-badge]: https://img.shields.io/npm/v/netlify-shortener.svg?style=flat-square
[package]: https://www.npmjs.com/package/netlify-shortener
[downloads-badge]: https://img.shields.io/npm/dm/netlify-shortener.svg?style=flat-square
[npmtrends]: http://www.npmtrends.com/netlify-shortener
[license-badge]: https://img.shields.io/npm/l/netlify-shortener.svg?style=flat-square
[license]: https://github.com/kentcdodds/netlify-shortener/blob/main/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/kentcdodds/netlify-shortener/blob/main/CODE_OF_CONDUCT.md
[emojis]: https://github.com/all-contributors/all-contributors#emoji-key
[all-contributors]: https://github.com/all-contributors/all-contributors
[all-contributors-badge]: https://img.shields.io/github/all-contributors/kentcdodds/netlify-shortener?color=orange&style=flat-square
[bugs]: https://github.com/kentcdodds/netlify-shortener/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug
[requests]: https://github.com/kentcdodds/netlify-shortener/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement
[good-first-issue]: https://github.com/kentcdodds/netlify-shortener/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement+label%3A%22good+first+issue%22[npm-bin]: https://docs.npmjs.com/files/package.json#bin