Coder Social home page Coder Social logo

mattfeng / gatsby-remark-numbered-footnotes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jlengstorf/gatsby-remark-numbered-footnotes

0.0 1.0 0.0 93 KB

A small plugin to change named footnotes to numbered footnotes in your Gatsby pages using Markdown.

JavaScript 100.00%

gatsby-remark-numbered-footnotes's Introduction

gatsby-remark-numbered-footnotes

This is a plugin for gatsby-transformer-remark that converts footnote reference links to sequential numbers.

It’s a lightweight wrapper around remark-numbered-footnotes to make it work with Gatsby.

Installation

yarn add gatsby-remark-numbered-footnotes

In gatsby-config.js, add:

  module.exports = {
    plugins: [
      {
        resolve: 'gatsby-transformer-remark',
        options: {
+         plugins: [
+           'gatsby-remark-numbered-footnotes',
+         ],
        },
      },
    ],
  };

Example Output

In Remark, it’s possible to add footnotes in Markdown like this:

This is normal body copy.[^also] It includes a couple footnotes.[^thing]

[^also]:
  This is a footnote.

[^thing]:
  This is another footnote.

By default, this will generate the following HTML:

<p>
  This is normal body copy.
  <sup id="fnref-also">
    <a href="#fn-also" class="footnote-ref">also</a>
  </sup>
  It includes a couple footnotes.
  <sup id="fnref-thing">
    <a href="#fn-thing" class="footnote-ref">thing</a>
  </sup>
</p>
<div class="footnotes">
  <hr>
  <ol>
    <li id="fn-also">
      <p>This is a footnote.</p>
      <a href="#fnref-also" class="footnote-backref"></a>
    </li>
    <li id="fn-thing">
      <p>This is another footnote.</p>
      <a href="#fnref-thing" class="footnote-backref"></a>
    </li>
  </ol>
</div>

With gatsby-remark-numbered-footnotes, the markup will change to:

  <p>
    This is normal body copy.
-   <sup id="fnref-also">
+   <sup id="fnref-1">
-     <a href="#fn-also" class="footnote-ref">also</a>
+     <a href="#fn-1" class="footnote-ref">1</a>
    </sup>
    It includes a couple footnotes.
-   <sup id="fnref-thing">
+   <sup id="fnref-2">
-     <a href="#fn-thing" class="footnote-ref">thing</a>
+     <a href="#fn-2" class="footnote-ref">2</a>
    </sup>
  </p>
  <div class="footnotes">
    <hr>
    <ol>
-     <li id="fn-also">
+     <li id="fn-1">
        <p>This is a footnote.</p>
-       <a href="#fnref-also" class="footnote-backref">↩</a>
+       <a href="#fnref-1" class="footnote-backref">↩</a>
      </li>
-     <li id="fn-thing">
+     <li id="fn-2">
        <p>This is another footnote.</p>
-       <a href="#fnref-thing" class="footnote-backref">↩</a>
+       <a href="#fnref-2" class="footnote-backref">↩</a>
      </li>
    </ol>
  </div>

gatsby-remark-numbered-footnotes's People

Contributors

jlengstorf avatar dependabot[bot] avatar mattfeng avatar dirtyf avatar manoellobo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.