# Static UNDRR header, navigation and footer

Use this recipe for a standalone page that belongs inside the UNDRR website's
global identity and navigation. A report-specific hero or hub header sits below
that shell. A widget embedded in an existing site should use its host's shell;
do not add a second header/footer. Other brands and microsites may need their
own navigation rather than the UNDRR.org menu.

Mangrove owns component markup and behavior. The consuming page owns the menu
source, language destinations, footer syndication and fallback content. Read
[PageHeader](https://mangrove.undrr.org/ai-components/components-pageheader.json)
and [MegaMenu](https://mangrove.undrr.org/ai-components/components-navigation-megamenu.json)
before building the shell. Follow their `detailsUrl` from the
[component index](https://mangrove.undrr.org/ai-components/index.json) if IDs change.

## Assets and header

1. Load `https://assets.undrr.org/mangrove/2.3.0/css/style.css` and use that same
   version for all Mangrove modules. Published packages are generated by the build;
   no package directory needs committing.
2. Use PageHeader's rendered markup for the toolbar and decoration. The horizontal
   logo is `https://assets.undrr.org/logos/undrr/undrr-logo-horizontal.svg`; link it
   to `https://www.undrr.org/`. Use meaningful alt text and explicit dimensions.
   Adapt the other destinations too: change the example's `/user` account link
   to `https://www.undrr.org/user` if the account action is needed, or remove it.
   Use `.mg-page-header__select-wrapper` if using its language dropdown.
3. Add a skip link targeting `<main id="main" tabindex="-1">`. Place the main
   navigation after the toolbar and before the page's own hero/navigation.
4. MegaMenu needs React; CSS and rendered HTML alone do not supply its interaction.
   For an unbundled page, place the pinned React/React DOM import map from the
   component's hydration example before module scripts. Keep those dependency
   versions compatible and identical across imports. A bundled site should use
   its existing dependency setup rather than load a second React instance.

Use language links with `lang` and `hreflang`, marking the current language, when
translations exist. Replace the example's Drupal language form: its
`action="/" method="post"`, language-code option values and no-JavaScript submit
button depend on Drupal handling the request and do not work on a static host.
Language links alone are sufficient. If using a dropdown, label it, supply real
destination URLs as option values and implement navigation to the selected URL.
Provide ordinary language links as a no-JavaScript fallback and remove the Drupal
form submission behavior. A styled `<select>` does not navigate on its own.
Offer only real destinations. Distinguish translations of this page from links
to UNDRR language homepages. Set page `lang`/`dir` and menu language/labels
appropriately; selecting a translated menu is separate from translating the
report content.

## Prepare the menu snapshot

The [UNDRR site-menu API](https://www.undrr.org/api/v2/taxonomy/site_menu) returns
flat taxonomy records in `results`, **not** MegaMenu `sections`. For the English
UNDRR.org global menu, start from root term **1413** (checked 29 October 2026).
Other languages/menus need their own root and source configuration.

To refresh a local snapshot:

1. Fetch the API response in a preparation script with HTTP/status and JSON checks.
2. Filter by `langcode` before assembling the tree. Select descendants of the
   configured root through `parent_target_id`; do not include unrelated menus.
3. Sort siblings by numeric `weight`, retaining source order for ties. Map `name`
   to `title`, `field_url` to `url` and children to `items`; resolve relative URLs
   against `https://www.undrr.org/`. For a top-level section, follow the current
   MegaMenu schema for its overview/banner link rather than invent a section prop.
4. Decode entities in text. MegaMenu renders `bannerDescription` as raw HTML:
   sanitize any description HTML before passing it, or omit the field. Do not
   copy `description__value` into it unchecked. Treat alternative URL fields as
   an explicit source-specific choice.
5. Save the transformed `sections` with source URL, root term, language and
   retrieval time. Render ordinary navigation links from the same snapshot into
   the initial HTML so navigation works before hydration and without JavaScript.

A consumer wrapper can supply the prepared sections directly:

```js
// Module script, after the import map; markup contains [data-global-navigation].
const container = document.querySelector('[data-global-navigation]');
const fallback = container.innerHTML;
const restore = () => {
  container.innerHTML = fallback;
  delete container.dataset.mgHydrated;
};
try {
  const [{ default: createHydrator }, { default: MegaMenu }, response] = await Promise.all([
    import('https://assets.undrr.org/mangrove/2.3.0/components/hydrate.js'),
    import('https://assets.undrr.org/mangrove/2.3.0/components/MegaMenu.js'),
    fetch('./assets/data/global-menu.json'),
  ]);
  if (!response.ok) throw new Error('Menu snapshot unavailable');
  const { sections } = await response.json();
  if (!Array.isArray(sections) || !sections.length) throw new Error('Empty menu snapshot');
  createHydrator({
    selector: '[data-global-navigation]',
    component: MegaMenu,
    fromElement: () => ({ sections }),
    options: { onError: restore },
  });
} catch {
  restore();
}
```

Adapt the snapshot path to the page URL. Pass localized labels/language as
specified by the component contract. Keep fallback links usable if module loading,
JSON parsing or hydration fails. Recheck desktop dropdowns, mobile drill-down,
keyboard dismissal and focus return after integration.

## Syndicate the global footer

The global footer is Drupal node **83835**. The English source is:

```text
https://www.undrr.org/api/v2/content/landingpage?id=83835&suffixid=footer&langcode=en
```

Read `results[0].body` as the source-owned footer HTML. The existing global footer
is English-only; retain English as a fallback if requesting another language
returns no content. Preserve shared copy rather than manually maintaining a
second footer.

Use a preparation/build script to fetch and validate a nonempty `footer.mg-footer`,
resolve relative links and asset URLs against `https://www.undrr.org/`, and render
the result into the page. Retain the last good snapshot if fetching or validation
fails. Record the source URL, node, language, retrieval time and content hash;
document the project's refresh command in its README.

A runtime refresh is optional. If used, apply a finite timeout and the same
validation/URL handling, then replace only the footer container after success.
Keep the pre-rendered footer on failure. Process syndicated HTML through the
consumer's established trusted-content/sanitization policy; removing script tags
alone is not a general sanitizer. Avoid re-running inline scripts from the feed.

## Check the complete shell

Serve the page over HTTP. Check header/hero/sticky-nav layering, footer links,
narrow widths, keyboard access, translated labels and RTL when applicable.
Block the menu CDN and footer API separately, and disable JavaScript: the saved
navigation and footer should still be available. Review fresh snapshots before
publishing; a successful fetch alone does not confirm the intended menu or footer.

Before release, follow the Mangrove guide's required-assets section for analytics,
critical messaging and cookie consent, accounting for what the host already loads.
Do not duplicate global integrations in an embedded page.
