Move creation of 404 page to page composer
Currently, the logic to create and compose the 404 page is hanging off the end of the site generator. This feels awkward and limits what we can do to prepare this page. Short term, I'd like to introduce a new function on the page composer that will encapsulate the logic to create and compose this file. The function should be named create404Page
and it should either be attached to the composePage
function and/or exported alongside it.
Here's how this new function would be used in site generator:
vars.siteCatalog.addFile(composePage.create404Page())
NOTE: The reason the function is attached to composePage is because it's a curried function that has access to the page composer environment.
As an additional step, I think the generator should pass the site-wide AsciiDoc config (siteAsciiDocConfig
) into this function so the 404 page can have access to site-wide page attributes via page.attributes
. The UI page model for the 404 page should also have the property 404
set to true
(i.e., page.[404]
). That way, UI templates can more easily detect when they are processing the 404 page.
In a future minor or major version of Antora, I think we should consider classifying the 404 page in the content catalog as a synthetic page. This a) allows it to be processed / composed like any other page and, as such b) allows the user to provide custom content using the 404.adoc page in the ROOT module of the ROOT component. If the user specifies a 404.adoc page, Antora only needs to mark it as special (mark it as 404 and set the 404 layout if a layout is not specified), but otherwise process it as is. However, there are some issues / consequences with this approach that need to be discussed in a separate issue.