Diplodoc file extension
![NPM version](https://img.shields.io/npm/v/@diplodoc/file-extension.svg?style=flat)
This is an extension of the Diplodoc platform, which allows adding links to files in the documentation.
The extension contains some parts:
Quickstart
Attach the plugin to the transformer:
import * as fileExtension from '@diplodoc/file-extension';
import transform from '@diplodoc/transform';
const {result} = await transform(
`
Download here: {% file src="path/to/file" name='readme.md' %}
`,
{
plugins: [fileExtension.transform({bundle: false})],
},
);
Prepared styles
It is necessary to add styles for file links on your page.
You can add assets files which were generated by the MarkdownIt transform plugin.
<html>
<head>
<link rel="stylesheet" href="_assets/file-extension.css" />
</head>
<body>
${result.html}
</body>
</html>
Or you can just include styles source code in your bundle.
import '@diplodoc/cut-extension/runtime/styles.css';
MarkdownIt transform plugin
Plugin for @diplodoc/transform package.
Options:
-
runtime.style
- name on runtime css file which will be exposed in results style
section.
(Default: _assets/file-extension.css
)
-
bundle
- boolean flag to enable/disable copying of bundled runtime to target directory.
Where target directore is <transformer output option>/<plugin runtime option>
Default: true
File markup
{% file src="path/to/file" name='readme.md' %}
==>
<a href="path/to/file" download="readme.md" class="yfm-file"><span class="yfm-file__icon"></span>readme.md</a>
Supported attributes:
Note: other attributes will be ignored
Plugin options
Name | Type | Description |
---|
fileExtraAttrs | [string, string][] | Adds additional attributes to rendered hyperlink |
CSS public variables
--yfm-file-icon
– sets custom file icon image--yfm-file-icon-color
– sets custom file icon color