Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vdegenne/coinmarketcap-s2l
https://github.com/vdegenne/coinmarketcap-s2l
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vdegenne/coinmarketcap-s2l
- Owner: vdegenne
- Created: 2022-01-15T17:38:43.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-20T13:55:19.000Z (about 2 months ago)
- Last Synced: 2024-11-20T14:34:13.008Z (about 2 months ago)
- Language: JavaScript
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# coinmarketcap-s2l
CoinMarketCap (s)ymbol (2)to (l)ink converter.
```javascript
import coinmarketcap from 'coinmarketcap-s2l'coinmarketcap('BTC') // returns https://coinmarketcap.com/currencies/bitcoin/
coinmarketcap('ADA') // returns https://coinmarketcap.com/currencies/cardano/
```## Installation
```bash
npm install coinmarketcap-s2l
```## Usage
Import in your app to generate link to coinmarketcap
```javascript
import coinmarketcap from 'coinmarketcap-s2l'const anchor = document.createElement('a')
anchor.href = coinmarketcap('BTC') // generates the coinmarketcap url from the symbol
anchor.innerText = `go to the BTC coinmarketcap information page`element.append(anchor)
```### In a webpage
If you want to use this extension in a static webpage your server needs to accept the cors.
Then you have to import the script :```html
import coinmarketcap from './node_modules/coinmarketcap-s2l/index.js'
window.coinmarketcap = coinmarketcap; // Make the function available globallyconst linkToAdaCoinMarketCapPage = coinmarketcap('ADA')
```
## Build this module
```bash
node ./scripts/coinmarketcap-fetch.mjs
npm run build
```