Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@diplodoc/file-extension

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diplodoc/file-extension

Template package for Diplodoc platform development

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
73
Maintainers
0
Weekly downloads
 
Created
Source

Diplodoc file extension

NPM version

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>
    <!-- Read more about '_assets/file-extension.css' in 'Transform plugin' section -->
    <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:

NameRequiredDescription
srcyesURL of the file. Will be mapped to href attribute
nameyesName of the file. Will be mapped to download attribute
lang-Language of the file content. Will be mapped to hreflang attribute
referrerpolicy-referrerpolicy attribute
rel-rel attribute
target-target attribute
type-type attribute

Note: other attributes will be ignored

Plugin options

NameTypeDescription
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

FAQs

Package last updated on 18 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc