Use links for navigation, not buttons that flip a local boolean. A published product URL must open the product page directly, and visitors must be able to follow its links without running a WebAssembly app.
Page keeps route paths and metadata keys together. Its relative Static site links also work when the site is hosted beneath a project path. The preview uses those same relative links and generated HTML, not a second router or a duplicate in-memory page.
The site-heading-1: semantic identifier follows the website template's heading convention and emits an HTML h1. Increasing a text size alone would not create that document heading.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"fission.toml","value":"fission-toml"},{"index":1,"label":"src/page.rs","value":"src-page-rs"},{"index":2,"label":"src/lib.rs","value":"src-lib-rs"},{"index":3,"label":"src/translations.rs","value":"src-translations-rs"},{"index":4,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":5,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}]}
{"id":"fission-tabs-1","index":0,"label":"fission.toml","value":"fission-toml"}
targets = ["static-site"]
[app]
name = "northstar-site"
app_id = "rs.example.northstar.site"
[site]
routes = []
entry = "crate::site_app"
title = "Northstar inventory software"
description = "Inventory software for independent retailers."
base_url = "https://northstar-site.example.com"
out_dir = "dist/site"
default_locale = "en-US"
locales = ["en-US", "es-ES"]
generate_sitemap = true
generate_robots = true
{"id":"fission-tabs-1","index":1,"label":"src/page.rs","value":"src-page-rs"}
use fission::prelude::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Page {
Home,
Inventory,
}
impl Page {
pub fn path(self) -> &'static str {
match self {
Self::Home => "/",
Self::Inventory => "/products/inventory/",
}
}
pub fn title_key(self) -> &'static str {
match self {
Self::Home => "search.home.title",
Self::Inventory => "search.inventory.title",
}
}
pub fn description_key(self) -> &'static str {
match self {
Self::Home => "search.home.description",
Self::Inventory => "search.inventory.description",
}
}
pub fn href(self, destination: Self) -> &'static str {
match (self, destination) {
(Self::Home, Self::Inventory) => "products/inventory/",
(Self::Inventory, Self::Home) => "../../",
_ => "./",
}
}
}
fission_component! {
pub SitePage<()> { props { page: Page } }
view(site, _state, cx) {
let tokens = &cx.view.env().theme.tokens;
let (heading, body, action, destination) = match site.page {
Page::Home => ("page.home.title", "page.home.description", "action.explore", Page::Inventory),
Page::Inventory => ("page.inventory.title", "page.inventory.description", "action.back", Page::Home),
};
} =>
Container(Column(gap: tokens.spacing.l, children: [
Wrap(spacing: tokens.spacing.m, children: [
Text(cx.tr("brand")).weight(tokens.typography.font_weight_bold),
Link::to(cx.tr("nav.home"), site.page.href(Page::Home)),
Link::to(cx.tr("nav.inventory"), site.page.href(Page::Inventory)),
]),
Divider(),
SemanticsRegion(
identifier: Some("site-heading-1:page-title".into()),
child: Text(cx.tr(heading))
.size(tokens.typography.heading1_size)
.weight(tokens.typography.font_weight_bold),
),
Text(cx.tr(body)).color(tokens.colors.text_secondary),
Link::to(cx.tr(action), site.page.href(destination)),
Text(cx.tr("site.scope")).color(tokens.colors.text_secondary),
]))
.padding_all(tokens.spacing.l)
.width_length(Length::percent(100.0))
.max_width(1100.0)
.bg(tokens.colors.background)
}
{"id":"fission-tabs-1","index":2,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod page;
mod translations;
#[cfg(not(target_arch = "wasm32"))]
pub fn site_app() -> fission::site::FissionSite {
use page::{Page, SitePage};
let env = translations::create_env();
let mut site = fission::site::FissionSite::new()
.with_env(env.clone())
.default_locale("en-US");
for page in [Page::Home, Page::Inventory] {
let title = env.i18n.get(&env.locale, page.title_key())
.expect("page title is translated").to_owned();
let description = env.i18n.get(&env.locale, page.description_key())
.expect("page description is translated").to_owned();
site = site.route_widget::<(), _>(
page.path(),
title,
Some(description),
SitePage::new(page),
);
}
site
}
#[cfg(not(target_arch = "wasm32"))]
pub fn build_site() -> anyhow::Result<()> {
fission::site::build_from_cli(site_app())
}
{"id":"fission-tabs-1","index":3,"label":"src/translations.rs","value":"src-translations-rs"}
use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;
use std::collections::HashMap;
const SOURCES: [(&str, &str); 2] = [
("en-US", include_str!("../i18n/en-US.yaml")),
("es-ES", include_str!("../i18n/es-ES.yaml")),
];
pub fn create_env() -> Env {
let mut env = Env::default();
env.locale = Locale::from("en-US");
for (locale, source) in SOURCES {
let messages: HashMap<String, String> =
serde_yaml::from_str(source).expect("valid tutorial translations");
env.i18n.add_bundle(TranslationBundle {
locale: Locale::from(locale),
messages,
});
}
env
}
{"id":"fission-tabs-1","index":4,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
site.a11y: "Northstar product website"
brand: "Northstar"
nav.home: "Home"
nav.inventory: "Product inventory"
page.inventory.title: "A clearer view of every product"
page.home.title: "Inventory software for independent retailers"
page.inventory.description: "Find stock gaps early and keep every shop location in sync."
page.home.description: "Keep stock counts, purchase orders and low-stock alerts together in one calm workspace."
action.back: "Back to Northstar"
action.explore: "Explore inventory features"
search.preview: "Search result preview"
search.inventory.title: "Product inventory for independent shops | Northstar"
search.home.title: "Inventory software for independent retailers | Northstar"
search.inventory.description: "Track stock across locations, spot low inventory and keep product records up to date."
search.home.description: "A straightforward inventory workspace for independent retailers: stock, orders and low-stock alerts."
site.scope: "Example product pages: no checkout, stock service or customer account is connected."
{"id":"fission-tabs-1","index":5,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
site.a11y: "Sitio web de productos de Northstar"
brand: "Northstar"
nav.home: "Inicio"
nav.inventory: "Inventario de productos"
page.inventory.title: "Una visión más clara de cada producto"
page.home.title: "Software de inventario para comercios independientes"
page.inventory.description: "Detecta pronto las faltas de stock y mantén sincronizadas todas las tiendas."
page.home.description: "Reúne recuentos, pedidos y avisos de poco stock en un espacio de trabajo claro."
action.back: "Volver a Northstar"
action.explore: "Ver las funciones de inventario"
search.preview: "Vista previa del resultado de búsqueda"
search.inventory.title: "Inventario de productos para tiendas independientes | Northstar"
search.home.title: "Software de inventario para comercios independientes | Northstar"
search.inventory.description: "Controla el stock entre tiendas, detecta niveles bajos y mantén los productos al día."
search.home.description: "Un espacio sencillo de inventario para tiendas independientes: existencias, pedidos y avisos de poco stock."
site.scope: "Páginas de ejemplo: no hay pagos, servicio de inventario ni cuentas conectados."
{"id":"fission-tabs-1"}