Skip to main content

Inject URL paramaters: turn a metapage into a configureable view

URLS: browser ?key=xyz with frame ?foo=_key_ becomes frame ?foo=xzy

Overview

URL parameters allow you to customize metapages by passing configuration values through the URL. This transforms static metapages into dynamically configurable views without modifying the underlying metapage.

In other words: a metapage becomes a function, or resolver,

You can add URL search and hash parameters to the metapage url, and those parameters will be passed down to the metaframes that have _key_ as hash or query param. e.g.

https://metapage.io/m/40e42e0e53224cf99c0d20fa1323c043?key=abc

This passes key=abc to the container metaframes.

https://some.frame/?foo=_key_

becomes

https://some.frame/?foo=abc

One of those builds a docker image from a git repository from a git tag: abc :

https://github.com/metapages/test-github-refs/tree/${key}

Now the entire metapage is configured to point to a specific git tag or commit sha.

How to Use URL Parameters in Different Metaframes

Javascript

Example metaframe

import { getHashParamFromWindow } from 'https://cdn.jsdelivr.net/npm/@metapages/hash-query@0.8.4/+esm'

const value = getHashParamFromWindow("key")
log(`key=${value}`)

The above code block shows how to access URL hash parameters that are injected from the main webpage.

Containers

You can use this mechanism to define the exact git repo the docker image is built from.

Any key=_value_ URL parameter is accessible by the container git repo URL and other places:

The git URL

The docker command

The container env vars

All browser URL parameters are available to the container environment as environment variables, except the following, which are used internally by the container metaframe, and thus cannot be overridden: [ autostart, control, config , debug, definition, inputs, queueOverride, ignoreQueueOverride, job, queue]

tip

User defined env vars is on the roadmap

Related topics