Astro Hackathon Showcase

📡 SSR

astro-git-view

by Siver K. Volle

GitHub Live Preview

README.md

Astro Git View

A server-side generated source code explorer for git-repositories, inspired by stagit, built with Astro

See astro-git and astro-lunr for the astro-plugins that supply most of the functionality.

Pure SSG demo on Github Pages

SSG/SSR-hybrid demo on git.kvissleik.no

The SSG/SSR-hybrid maintains the full tree-view for each included branch and tag, but specific commits and raw files are served using the SSR-module.

Commands

All commands are run from the root of the project, from a terminal:

CommandAction
npm ci --ignore-scriptsInstalls dependencies
npm run dev -- --experimental-integrationsStarts local dev server at localhost:3000
npm run build -- --experimental-integrationsBuild your production site to ./dist/
npm run preview -- --experimental-integrationsPreview your build locally, before deploying

Running SSR

in Docker

SSR is SSR-only, but for deployment, I want SSG for common resources, and SSR for the more obscure parts.

To use:

docker compose up -d

This will start a server at localhost:80

Standalone

npm run build-ssr -- --experimental-integrations
npm run serve-ssr -- --experimental-integrations

Then go to localhost:12549

Static assets are not included, meaning styling and scripting will be missing.

SSR + astro-lunr

Note that astro-lunr is currently not removing the <lunr-document/>-elements when hosted using SSR. (Seems like options.addRenderer is not included by the adapter?)

Therefore a temporary css-style of lunr-document {display: none} is included in main.css;

Description

The named branches and tags are built with SSG, while the full tree of every other commit - and the downloadable source files for branches/tags/commits - are handled by the SSR. To reach a commit’s tree, click on the commit-message in the history, from any point in the tree. To download a particular source file, click the “download”-link on the right side of each file-view. When the site is rebuilding, the old SSG-files are still served until the new ones are built, while the SSR is down. No space for puns, this time.