Making a frontend
Every site comes with one interface, in src/frontend/default, that shows images and, as options, 3D models, PDFs and deep zoom. It is a small React app that you can restyle. An interface that looks or works differently can take its place, and is best kept in a repository of its own, so that others can start from it.
What a frontend needs
Section titled “What a frontend needs”- Build with
npm install && npm run buildinto adist/folder holding anindex.html. - Refer to its files by relative paths, as Vite does with
base: './', so that the site also works under a path of another website. - Talk to the backend only through its HTTP API:
/api/..., listed at/docson a running site;/images/{id}?size=thumbnailorfull;/models/{id}for 3D models;/documents/{id}for PDFs.
The backend serves dist/ at the root of the site and fills the <title> and <meta name="description"> of index.html from collection.json. A frontend may also write dist/frontend.json, as {"media": ["3d"]}, to say which kinds of material it shows; python -m src.environment reports it.
Using one
Section titled “Using one”Clone it into src/frontend/<name> and run setup with its name, or give --frontend the path to a folder elsewhere:
git clone https://github.com/example/my-frontend src/frontend/my-frontendnpm run setup -- --frontend=my-frontendMade one that others could use? Tell us in Discussions.