exile.watch docs
  • Introduction
  • The Maven - exile.watch context
  • Projects
    • hideout
    • crucible
      • Contributing
    • writ
      • Contributing
    • splinters
      • Contributing
      • @exile-watch/vite-config
      • @exile-watch/biome-config
      • @exile-watch/typescript-config
      • @exile-watch/unit-testing-config
      • @exile-watch/lefthook-config
    • nucleus
      • Contributing (data)
        • Encounter token breakdown
      • Contributing (scripts)
        • Scripts definition
      • @exile-watch/encounter-data
      • @exile-watch/seo
    • malachai
      • Contributing
      • snap gyazo thumbnail
    • doryani
      • Contributing
      • Actions
        • Authenticate to GitHub Package Registry
        • Install npm dependencies
        • Code quality assurance
        • Deploy webapp
        • Publish package
        • Preview publish package
        • Preview deploy webapp
  • voidstone
    • Contributing
  • Development
    • Commit message guidelines
    • Prerequisites
    • Generating GitHub PAT
    • .npmrc file
  • Architecture
    • Dependencies
    • Tech stack
    • Adoption chart
    • GHA workflows web
  • Legal
    • License - FSL, Apache 2.0
    • Non-Affiliation Notice
    • Code of Conduct
    • Privacy Policy
Powered by GitBook
On this page
  • About @exile-watch/encounter-data
  • Usage

Was this helpful?

  1. Projects
  2. nucleus

@exile-watch/encounter-data

Data that powers exile.watch

PreviousScripts definitionNext@exile-watch/seo

Last updated 2 days ago

Was this helpful?

About

This package contains JSONs that power exile.watch.

This is ES module package only.

JSONs are generated based on the extracted YAML tokens. ()

Usage

The size of generated JSONs can be big (double digit kb)

It's advised to dynamically import them when needed in order to boost performance

  1. Install the package as a dependency:

npm i @exile-watch/encounter-data

  1. Example of dynamically importing the data

// ListEncounterCategories.tsx
import { CategoryPageType } from "@exile-watch/encounter-data";
import { SimpleGrid } from "@exile-watch/writ-react";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import { HomepageCard, SimpleCard } from "#components";

const ListEncounterCategories = () => {
  const {
    query: { directory, category },
  } = useRouter();
  const [data, setData] = useState<CategoryPageType | null>(null);

  useEffect(() => {
    import(
      `@exile-watch/encounter-data/dist/extracted-data/${directory}/${category}.esm` as string
    )
      .then((d) => {
        setData(d.default);
      })
      .catch(() => {
        setData(null);
      });
  }, [category]);

  return (
    <SimpleGrid
      cols={{ xxxl: 6, xxl: 5, xl: 4, lg: 3, md: 2, sm: 2, xs: 1 }}
      mb="md"
    >
      {data?.map((data) => (
        <HomepageCard key={data.path} {...data} />
      ))}
    </SimpleGrid>
  );
};

export default ListEncounterCategories;
@exile-watch/encounter-data
more on the process here