Skip to main content

MkDocs plugin for the Beacon search widget

Project description

beacon-mkdocs-plugin

MkDocs plugin that embeds the Beacon search widget into your documentation site.

Status

Pre-alpha. Not yet published to PyPI.

Install

Once released:

pip install mkdocs-beacon-search

Quick start

Add the plugin to your mkdocs.yml and point it at a Beacon API:

plugins:
  - beacon-search:
      api_url: https://search-api.example.com
      product: k0s

Run mkdocs build (or mkdocs serve locally). The plugin copies the widget bundle into the built site and mounts <beacon-search> into your theme automatically.

Configuration reference

Option Type Default Description
api_url URL — (required) Base URL of the Beacon search API.
product string (unset) Scope search to a single product. Maps to the widget's product attribute.
embed_id string (unset) Publisher-supplied identifier for analytics segmentation (e.g. footer-v1.31).
analytics on | off on Widget analytics posture. off fully opts the widget out (no script load, no events).
analytics_consent_required bool false When true, the widget defers analytics events until the host CMP dispatches beacon-analytics-consent-granted on document.
replace_search bool true On Material for MkDocs, replace the theme's built-in .md-search block with the widget. Set to false to keep both.
placement CSS selector (theme default) Override where the widget is mounted. When set, the plugin appends <beacon-search> inside the first matching element on every page.
enabled bool true Plugin master switch. Supports MkDocs' !ENV syntax for environment-gated builds.

Unknown keys are rejected. Missing api_url fails the build.

Theme compatibility

Theme Default placement Notes
material (Material for MkDocs) Replaces .md-search when replace_search: true; otherwise appends to .md-header__inner. Primary target. Tested against Material 9.x.
mkdocs (MkDocs built-in) Appends to .navbar. Works out of the box.
readthedocs (MkDocs built-in RTD theme) Appends to .wy-side-nav-search (or .wy-nav-top if absent). Best-effort.
Anything else No auto-placement. Set placement: to a CSS selector, or use the Jinja macro.

Manual placement (Jinja macro)

For full control, the plugin registers a {{ beacon_search() }} Jinja function. Use it inside a theme template override:

{# overrides/main.html #}
{% extends "base.html" %}
{% block content %}
  {{ beacon_search() }}
  {{ super() }}
{% endblock %}
# mkdocs.yml
theme:
  name: mkdocs
  custom_dir: overrides

When a page already contains a <beacon-search> element (from the macro or from markdown), auto-placement skips that page — no double-mount.

Content Security Policy

The widget is a pure <script> + custom element. If your site enforces CSP and you want widget analytics enabled:

  • script-src must allow https://www.googletagmanager.com
  • connect-src must allow https://www.google-analytics.com and https://*.analytics.google.com

If you set analytics: off, no third-party domains are contacted.

Migration from the <script> + custom element integration

If your site currently embeds the widget directly:

<script src="https://.../beacon-search.umd.js"></script>
<beacon-search api-url="..." product="k0s"></beacon-search>

Remove those two lines and add the plugin to mkdocs.yml. The plugin takes over script loading and element placement.

Development

See CONTRIBUTING.md.

License

Apache-2.0 — see LICENSE.

Contributing

Pull requests are welcome. See CONTRIBUTING.md for development setup.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_beacon_search-0.1.0.tar.gz (91.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_beacon_search-0.1.0-py3-none-any.whl (83.3 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_beacon_search-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocs_beacon_search-0.1.0.tar.gz
  • Upload date:
  • Size: 91.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for mkdocs_beacon_search-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0c4b7f05c64b4e2f11ebc1c08300f67f84fe2f8de7cc24a98fb03135d9b4de3
MD5 a6825d8f184c8ac6c42aa038bfcd8427
BLAKE2b-256 ed85e3e86f785e429c7ae8eed4d553aec6623a274b2e4943552abbd08e2ab643

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_beacon_search-0.1.0.tar.gz:

Publisher: release.yml on Mirantis/beacon-mkdocs-plugin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mkdocs_beacon_search-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_beacon_search-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb3bb03a859dd42b3dac52370ca50f31c1f9f529e24ed3967dbdcf3bc51cdd5a
MD5 e6d9e7c408b0496b63fd618be133a512
BLAKE2b-256 e2badbb558f7943b752cb05172fe23dada1ad58923190282ee6ff4591227ea14

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_beacon_search-0.1.0-py3-none-any.whl:

Publisher: release.yml on Mirantis/beacon-mkdocs-plugin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page