Open fwkoch opened 6 months ago
Very excited about this, especially around enabling parts to be defined by files in general.
We should make sure this works for site templates, including live reload if the part is a file path.
Ok - just hashing through things a bit to make sure I understand (1) the current state of things and (2) how to proceed...
parts
currently work?parts
may be defined in four ways:
project frontmatter parts
page frontmatter parts
tagged block
partimplicit parts
)project frontmatter parts
are simply ignored currentlypage frontmatter parts
become tagged blocks
and are prepended to the page content. These blocks are marked as visibility: remove
- the transform to do this is basically the first transform during mdast processing: https://github.com/jupyter-book/mystmd/blob/main/packages/myst-cli/src/process/mdast.ts#L170tagged blocks
are unchangedimplicit part
sections are unchangedtemplate.yml
defines parts
extractParts
- this pulls out tagged blocks
(which now include page frontmatter parts
) as well as implicit parts
.page frontmatter parts
that were not extracted do not show up, due to their visibility; tagged blocks
and implicit parts
defined in the page that were not extracted do show up, though.abstract
must be defined on one-page-and-only-one-page of the export)export
cannot set it's own export-specific parts
template.yml
could define parts
, but it currently does notmyst-theme
on a per-page basis. This uses the same extractParts
function as the static exports, but only applies to the hard-coded known parts: https://github.com/jupyter-book/myst-theme/blob/50c625864f091f52dc563cd3bd486e68de3625d1/packages/site/src/utils.ts#L21-L28project frontmatter parts
are ignored, page frontmatter parts
are removed, tagged blocks
remain.part
to be a file
files
parts
be processed as a "pseudo-file" rather than injected into the page tree
myst-theme
, i.e. we will need to pass frontmatter into these: https://github.com/jupyter-book/myst-theme/blob/50c625864f091f52dc563cd3bd486e68de3625d1/packages/site/src/utils.ts#L22 - not a big deal I suppose!site
to define parts
exports
to define parts
extractPart
for new part
definition locations
export
parts and fall back to existing logicparts
in template.yml
project frontmatter parts
site parts
, as they are both parts at the myst.yml
/config.json
levelproject frontmatter parts
over the existing page frontmatter part
logic.project frontmatter parts
if site-level and page-level parts, respectively, are not defined.parts
may either be (1) at the project level (so for each build there must only be one) or (2) at the page level (so for each page in the build there must be one - these are like the hard-coded parts supported in the site theme)
template.yml#parts
to specify kind: page / project
or something
Individual files allow
parts
to be defined in their frontmatter. These are respected for static exports of those files. However, parts cannot be defined at the project/export level. We should extend the frontmatterparts
to be allowed there:Additionally, it would be nice to allow these to be paths to files rather than inline text.