Hawk JS version 1.0.5

hawk() Function

The hawk() function is the central part of Hawk JS, used for generating and submitting sitemaps or updated route links based on various SEO strategies. It automates the handling of updated routes and manages the sitemap generation and submission process.

Function Signature

async function hawk(
  strategy: suppotredStrategies,
  lookupPatterns: string[] = [],
  ignorePattern: string[] = [],
  prettify: boolean = true
): Promise<void>

Parameters and Explanation

  • strategy (suppotredStrategies): The strategy to use for submission. Options include GIndex, IndexNow, GWebmaster, and GWebmaster2.

  • lookupPatterns (string[]): Patterns to specify which files to include in the sitemap generation and updated routes lookup.

  • ignorePattern (string[]): Patterns to specify which files to exclude from the sitemap generation and updated routes lookup.

  • prettify (boolean): Flag to format the sitemap for readability. Default is true.

Example Usage

import { hawk } from '@cresteem/hawk-js';
 
async function main() {
  const strategy = 'GWebmaster2'; // Choose your strategy
  const lookupPatterns = ['**/*.html'];
  const ignorePattern = ['node_modules/**'];
  const prettify = true;
 
  try {
    await hawk(strategy, lookupPatterns, ignorePattern, prettify);
    console.log('Sitemap generated and submitted successfully.');
  } catch (err) {
    console.error('Error:', err);
  }
}
 
main();



Keywords:
  • open-source tools
  • website indexing
  • search engine optimization