Assign media type in content classifier
Currently, the media type (e.g., text/asciidoc) is resolved and assigned to the virtual file by the content aggregator. However, there are many other ways a file can get into the content catalog (in core, aliases are the main example). In these scenarios, the burden falls on the calling code to resolve and assign the media type (which likely means depending on the mime-types module).
It would be better to defer the media type assignment to content classification and handle it inside ContentCatalog#addFile
. In fact, this addFile
method should compute and assign all mandatory properties on src
if the object passed in is not fully prepared (detecting whether or not it came from the content aggregator). In addition to src.mediaType
, this includes computing and assigning src.basename
, src.extname
, and src.stem
.
This change simplifies the call to add a file to the content catalog so that only the contents and resource ID are required:
contentCatalog.addFile({
contents: Buffer.from('contents'),
src: { component: 'project', version: '1.0', module: 'ROOT', family: 'page', relative: 'index.adoc' }
})
The path
property is recommended (for messages), but not mandatory.