diff --git a/.env b/.env index 182dc6a..b8883d9 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VITE_GUIDE_ASSETS_URL=https://guide-assets.appliedenergistics.org/index.json +GUIDE_ASSET_INDEX_PATH=data/index.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index a7930b6..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - env: { browser: true, es2020: true }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', - ], - parser: '@typescript-eslint/parser', - parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': 'warn', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-empty-function': 'off', - }, -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..bffb357 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "next/core-web-vitals" +} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1995d82..ab8a3a3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,16 +31,18 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: "18" + node-version: "20" cache: npm - name: Install dependencies run: npm ci + - name: Download Assets + run: node scripts/download_data.mjs - name: Build run: npm run build - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: - path: ./dist + path: ./out # Deployment job deploy: diff --git a/.gitignore b/.gitignore index a547bf3..39a2043 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,36 @@ -# Logs -logs -*.log +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules + +# source build-data +/data/ + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug npm-debug.log* yarn-debug.log* yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/index.html b/index.html deleted file mode 100644 index 49bf1b2..0000000 --- a/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - -
- - - -An unknown error occurred
--
{JSON.stringify(error, null, 2)}- - > - ); -} - -export default GuidebookPageError; diff --git a/src/components/GuidebookPageNotFound.tsx b/src/components/GuidebookPageNotFound.tsx deleted file mode 100644 index d95ef70..0000000 --- a/src/components/GuidebookPageNotFound.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { useLocation } from "react-router-dom"; - -function GuidebookPageNotFound() { - const location = useLocation(); - - return ( - <> -
The page {location.pathname} was not found.
- > - ); -} - -export default GuidebookPageNotFound; diff --git a/src/components/GuidebookPageRoute.tsx b/src/components/GuidebookPageRoute.tsx deleted file mode 100644 index f3da993..0000000 --- a/src/components/GuidebookPageRoute.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { ExportedPage, useGuide } from "../data/Guide.ts"; -import { compilePage } from "../page-compiler/compilePage.tsx"; -import { useEffect, useMemo } from "react"; -import { useGuidePageTitleSetter } from "./GuidePageTitleProvider.ts"; - -export type GuidebookPageRouteProps = { - pageId: string; - page: ExportedPage; -}; - -function GuidebookPageRoute({ pageId, page }: GuidebookPageRouteProps) { - const guide = useGuide(); - const { title, content } = useMemo( - () => compilePage(guide, pageId, page), - [guide, pageId, page] - ); - const setPageTitle = useGuidePageTitleSetter(); - useEffect(() => setPageTitle(title), [setPageTitle, title]); - return content; -} - -export default GuidebookPageRoute; diff --git a/src/components/ItemInfoImage.tsx b/src/components/ItemInfoImage.tsx new file mode 100644 index 0000000..e51936d --- /dev/null +++ b/src/components/ItemInfoImage.tsx @@ -0,0 +1,22 @@ +"use client"; + +import React from "react"; +import { ItemInfo } from "../build-data/Guide.ts"; + +export interface ItemInfoImageProps { + baseUrl: string; + itemInfo: ItemInfo; +} + +function ItemInfoImage({ baseUrl, itemInfo }: ItemInfoImageProps) { + return ( + + ); +} + +export default ItemInfoImage; diff --git a/src/components/ItemTooltip.tsx b/src/components/ItemTooltip.tsx index 0280e03..1793a0b 100644 --- a/src/components/ItemTooltip.tsx +++ b/src/components/ItemTooltip.tsx @@ -1,13 +1,14 @@ import { PropsWithChildren } from "react"; -import ItemIcon from "./ItemIcon"; import css from "./ItemTooltip.module.css"; import "tippy.js/dist/svg-arrow.css"; -import { ItemInfo } from "../data/Guide.ts"; +import { ItemInfo } from "../build-data/Guide.ts"; import MinecraftTooltip from "./MinecraftTooltip.tsx"; +import ItemInfoImage from "@component/ItemInfoImage.tsx"; export type TooltipMode = "text" | "icon"; export interface ItemTooltipProps { + baseUrl: string; item: ItemInfo; mode?: TooltipMode; } @@ -41,10 +42,16 @@ function ItemName({ item }: { item: ItemInfo }) { /** * Displays the content of an item tooltip. */ -function ItemTooltipContent({ item, mode = "icon" }: ItemTooltipProps) { +function ItemTooltipContent({ + baseUrl, + item, + mode = "icon", +}: ItemTooltipProps) { return ( <> - {mode === "icon" ?The page {pathname} was not found.
+ > + ); +} + +export default GuidebookPageNotFound; diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx new file mode 100644 index 0000000..6535a8f --- /dev/null +++ b/src/pages/_error.tsx @@ -0,0 +1,23 @@ +import { NextPageContext } from "next/dist/shared/lib/utils"; + +interface GuidebookPageError { + error: any; +} + +function GuidebookPageError({ error }: GuidebookPageError) { + return ( + <> +An unknown error occurred
++
{JSON.stringify(error, null, 2)}+ + > + ); +} + +GuidebookPageError.getInitialProps = ({ res, err }: NextPageContext) => { + return { error: err }; +}; + +export default GuidebookPageError; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts deleted file mode 100644 index 11f02fe..0000000 --- a/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -///