1.7.0-alpha.1 • Published 3 years ago

@guanghechen/gatsby-transformer-yozora v1.7.0-alpha.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

A gatsby plugin for transforming markdown files to markdown ast through Yozora Parser, Inspired by gatsby-transformer-remark.

Install

This plugin depends on Yozora Parser, as of now, you can choose @yozora/parser (Recommend) or @yozora/parser-gfm or @yozora/parser-gfm-ex.

  • npm

    npm install @guanghechen/gatsby-transformer-yozora @yozora/parser --save-dev
  • yarn

    yarn add @guanghechen/gatsby-transformer-yozora @yozora/parser --dev

Usage

Add configs in gatsby-config.js:

// gatsby-config.js
const { YozoraParser } = require('@yozora/parser')

module.exports = {
  plugins: [
    {
      resolve: '@guanghechen/gatsby-transformer-yozora',
      options: {
        parser: new YozoraParser(),
        preferFootnoteReferences: true,
        frontmatter: {
          excerpt_separator: '<!-- more -->',
        }
      }
    }
  ]
}

Options

NameRequiredDefault
parsertrue-
preferFootnoteReferencesfalsefalse
presetDefinitionsfalse-
presetFootnoteDefinitionsfalse-
headingIdentifierPrefixfalseheading-
footnoteIdentifierPrefixfalsefootnote-
shouldStripChineseCharsfalsefalse
wordsPerMinutefalse80
frontmatterfalse-
pluginsfalse-
  • parser: A yozora parser.

  • preferFootnoteReferences: Replace footnotes into footnote references and footnote reference definitions.

  • presetDefinitions: Preset link reference definitions.

  • presetFootnoteDefinitions: Preset footnote reference definitions.

  • headingIdentifierPrefix: The identifier prefix of the headings that constitutes the toc (Table of Content).

  • footnoteIdentifierPrefix: The identifier prefix of the footnote references and footnote reference definitions.

  • shouldStripChineseChars: Whether to remove line end between two chinese characters.

  • wordsPerMinute: The number of words read per minute.

  • frontmatter: Options for gray-matter.

  • plugins: Plugins of @guanghechen/gatsby-transformer-yozora, similar with the plugins option of gatsby-transformer-remark.

    /**
    * Api passed to the options.plugins
    */
    export interface AstMutateApi {
      files: Node[]
      markdownNode: Node
      markdownAST: Root
      pathPrefix: string
      getNode(id: string): Node
      reporter: Reporter
      cache: GatsbyCache
    }
    
    function plugin(api: AstMutateApi, pluginOptions: any): void
    • api: passed by @guanghechen/gatsby-transformer-yozora
    • pluginOptions: defined in gatsby-config.js, such as the highlighted line in the following code (line eight)

      {
        resolve: '@guanghechen/gatsby-transformer-yozora',
        options: {
          parser: new YozoraParser(),
          plugins: [
            {
              resolve: '@guanghechen/gatsby-yozora-images',
              options: {},    // this is the pluginOptions.
            },
          ],
        },
      }

FAQ

Related

1.5.4

3 years ago

1.6.0

3 years ago

1.7.0-alpha.1

3 years ago

1.7.0-alpha.0

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago