CLI tool for generating git.io shortlinks
yarn add @tinypixelco/gitio
Pass either the full url or URI
yarn gitio https://github.com/pixelcollective/gitio
🔗 pixelcollective/gitio https://git.io/JTNxu
yarn gitio pixelcollective/gitio
🔗 pixelcollective/gitio https://git.io/JTNxu
Separate URLs with a space to run a batch:
yarn gitio sindresorhus/cli-spinners/blob/master/spinners.json roots/bud-support
🔗 sindresorhus/cli-spinners/blob/master/spinners.json https://git.io/JTN9G
🔗 roots/bud-support https://git.io/JTNQ9
Get JSON with --json
flag:
yarn gitio sindresorhus/cli-spinners/blob/master/spinners.json roots/bud-support --json
[{"full":"https://github.com/sindresorhus/cli-spinners/blob/master/spinners.json","short":"https://git.io/JTN9G"},{"full":"https://github.co
m/roots/bud-support","short":"https://git.io/JTNQ9"}]
Use the shortenUrl
function exported by this package.
import { shortenUrl } from "@tinypixelco/gitio";
(async () => {
const url = await shortenUrl("pixelcollective/gitio");
console.log(url);
})();
You can also shorten in bulk with shortenUrls
:
import { shortenUrls } from "@tinypixelco/gitio";
(async () => {
const urls = await shortenUrls([
"pixelcollective/gitio",
"sindresorhus/cli-spinners",
]);
console.log(urls);
})();
This also exports a React hook:
import React from "react";
import { useGitioUrls } from "@tinypixelco/gitio";
const Component = ({requests: string[]}) => {
const [urls, err] = useGitioUrls(requests);
if (!err && !urls) return null
return err ? err : urls
};
MIT © Tiny Pixel Collective