Skip to content

Every undeclared site.options key is dropped by the CLI, so twitter and launch_* never reach the theme #173

Description

@mmcky

Found while building Phases 4–5 (#90, #91). The MyST CLI validates site.options against the template's declared options and drops every key the template does not declare (validateTemplateOptions in myst-templates: the output object is built only from the declared definitions; unknown keys log at debug level). Until #90's branch, this theme's template.yml declared no options at all, so config.options arrived as {} on every site. Verified on the visual fixture, whose site.options.logo_text never appears in _build/site/config.json.

That means several options the theme reads have never worked from myst.yml:

Read in Key Effect today
app/root.tsx, both page routes twitter Twitter card meta never gets the handle
app/components/toolbar/LaunchButton.tsx launch_repo_url, launch_repo_suffix, launch_branch, launch_notebooks_path, launch_source_path the launcher always uses the defaults; the generalisation in launchUrls.ts is unreachable from config
app/backend/loaders.server.ts favicon always the mystmd default
app/components/Document.tsx (upstream shape) analytics_google, analytics_plausible no analytics can be configured
app/components/Page.tsx hide_toc, hide_search, hide_outline, hide_title_block, outline_maxdepth, hide_footer_links ignored
fixture logo_text ignored

Page-level site: frontmatter is a different path. The CLI validates it with the same definitions but, when the validated result is empty, leaves the page's raw site: block in place. That is the only reason site.git_metadata works on the fixture's features page and in the git-metadata plugin's override. Two consequences worth knowing:

  1. A page that sets any declared key under site: has its whole block replaced by the validated keys, so an undeclared git_metadata on that page is silently lost. Phase 4 — Internationalisation (language switcher + hreflang) #90's branch documents this in app/types.ts and keeps the two on different fixture pages.
  2. A declared option's default: is written into every page's validated block even when the page set nothing, which then overrides the site-wide value. Phase 4 — Internationalisation (language switcher + hreflang) #90's branch therefore declares no defaults in template.yml and applies them in code.

Proposed fix. Declare in template.yml every option the theme reads, one options: entry each (twitter, the five launch_*, favicon as type file, the two analytics_*, the hide_* / outline_maxdepth set), with no default: values, and add a fixture assertion that a declared option reaches config.options. Then decide what to do about git_metadata: it is an object, which a template option cannot declare, so the page-level override survives only by the empty-validation quirk above. Moving the page-level override to mdast.data (where the plugin already writes) would take it off that path.

Options that cannot be declared. Template option types are boolean, string, number, choice and file only. Any structured option has to be a string (#90 uses a YAML block string for languages and translators) or live somewhere the CLI preserves. A real list / object option type in the engine would remove the workaround; that is a QuantEcon/mystmd (and upstream) change, not a theme one, and is noted on the upstream-candidates ledger.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is wrong or broken in a lecture or build

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions