Skip to content

indexToObject

For static sites, you can pre-generate indices with SSG during build time to optimize page load performance:

function indexToObject(index: StaticSeekIndex): StaticSeekIndexObject;
  • index: A StaticSeekIndex object that represents the index you want to convert to a JSON-compatible format.

The function returns a StaticSeekIndexObject, a JavaScript object.

import { createIndex, LinearIndex, StaticSeekError, indexToObject } from "staticseek";
const index = createIndex(LinearIndex, array_of_articles);
if (index instanceof StaticSeekError) throw index;
const json = JSON.stringify(indexToObject(index));
// Write the json to a file and upload it to the host