Restore the missing external congrats page

This commit is contained in:
Damien Elmes 2025-01-24 16:19:55 +11:00
parent bc48eb4595
commit 774d57cdc8
3 changed files with 31 additions and 11 deletions

View file

@ -184,11 +184,16 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
let group = format!("ts:{name}");
let deps = inputs![deps, glob!(format!("ts/{name}/**"))];
let extra_exts = if html { &["css", "html"][..] } else { &["css"] };
let entrypoint = if html {
format!("ts/routes/{name}/index.ts")
} else {
format!("ts/{name}/index.ts")
};
build.add_action(
&group,
EsbuildScript {
script: inputs!["ts/bundle_svelte.mjs"],
entrypoint: inputs![format!("ts/{name}/index.ts")],
entrypoint: inputs![entrypoint],
output_stem: &format!("ts/{name}/{name}"),
deps: deps.clone(),
extra_exts,
@ -212,6 +217,16 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
":sveltekit",
],
)?;
build_page(
"congrats",
true,
inputs![
//
":ts:lib",
":ts:components",
":sass",
],
)?;
Ok(())
}

View file

@ -1,5 +1,5 @@
@use "../lib/sass/root-vars";
@import "../lib/sass/base";
@use "../../lib/sass/root-vars";
@import "../../lib/sass/base";
@import "bootstrap/scss/containers";

View file

@ -1,29 +1,34 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
//
// This old non-Sveltekit entrypoint has been preserved for AnkiWeb compatibility,
// and can't yet be removed. AnkiWeb loads the generated .js file into an existing
// page, and mounts into a div with 'id=congrats'. Unlike the desktop, it does not
// auto-refresh (to reduce the load on AnkiWeb).
import "./congrats-base.scss";
import { congratsInfo } from "@generated/backend";
import { ModuleName, setupI18n } from "@tslib/i18n";
import { checkNightMode } from "@tslib/nightmode";
import { mount } from "svelte";
import CongratsPage from "./CongratsPage.svelte";
const i18n = setupI18n({ modules: [ModuleName.SCHEDULING] });
export async function setupCongrats(): Promise<CongratsPage> {
export async function setupCongrats(): Promise<void> {
checkNightMode();
await i18n;
const customMountPoint = document.getElementById("congrats");
const info = await congratsInfo({});
const page = new CongratsPage({
// use #congrats if it exists, otherwise entire body
target: customMountPoint ?? document.body,
props: { info, refreshPeriodically: !customMountPoint },
});
return page;
const props = { info, refreshPeriodically: false };
mount(
CongratsPage, // use #congrats if it exists, otherwise entire body
{ target: customMountPoint ?? document.body, props },
);
return;
}
setupCongrats();