indexnow
Version:
An IndexNow wrapper for TypeScript/JavaScript.
45 lines (30 loc) • 1.03 kB
Markdown
An IndexNow wrapper for TypeScript/JavaScript.
```bash
npm i indexnow
yarn add indexnow
```
```js
import IndexNow from 'https://deno.land/x/indexnow.js@0.1.0/mod.ts'
```
You can use the library using a functional or object-based approach.
```js
// functional
const { indexNow } = require('indexnow')
const key = "my-key"
const engine = SEARCH_ENGINES.BING
indexNow('https://example.com/new_page', engine, key)
// NOTE: First string in the list is used as the host, and will not be submitted
indexNow(['https://example.com', 'https://example.com/page1', 'https://example.com/page2'], engine, key)
// object-oriented
const IndexNow, { SEARCH_ENGINES } = require('indexnow')
const indexer = new IndexNow(SEARCH_ENGINES.BING, '<key>') // keyLocation is an optional third argument
indexer.submitUrl('https://example.com/new_page', key)
indexer.submitUrls('https://example.com', ['https://example.com/page1', 'https://example.com/page2'], key)
```