npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pilvit/post-references

v1.0.0

Published

A collection of citation components for articles written in React or MDX.

Downloads

15

Readme

Post References

This is a package of React components to create citations for your blog posts. It works best with MDX and static site generators.

npm -i @pilvit/post-references

Motivation

Many blog posts use links to their references, but this doesn't work with well scientific literature or books. Another approach is to use <cite> HTML built-in tag, it is good if you refer to a licensed content.

In our approach you can define citation style and the respective bibliography is printed and citation formatted. The format is inspired from BibTex. The numbering is automatic, and items are sorted by author names.

Example in MDX

---
title: Example Post
---

Lorem lipsum... <Cite id="sicp" meta="p. 20–25" />

More text <Cite id="tex" /> here...

<Bibliography data={{
    sicp: {
        type: "book",
        title: "Structure and Interpretation of Computer Programs",
        authors: ["Harold Abelson", "Gerald Jay Sussman", "Julie Sussman"],
        year: 1985,
        publisher: "MIT Press"
    },
    tex: {
        type: "web",
        title: "TeX",
        authors: ["Wikipedia"],
        link: "https://en.wikipedia.org/wiki/TeX"
    }
}}/>

In static-site generators such as Gatsby and Next.js you can define a template:

import {Bibliography, Cite, CiteContextProvider} from "@pilvit/post-references";
import {DefaultRenderer} from "@pilvit/post-references/renderers/DefaultRenderer";
import {defaultCiteFormatter} from "@pilvit/post-references/renderers/defaultCiteFormatter";

export const Template = () => {
    return (
        <CiteContextProvider>
            <MDXProvider components={{
                Cite,
                Bibliography
            }}>
                {/* MDXRenderer */}
            </MDXProvider>
        </CiteContextProvider>
    )
}

By default, it adds the cite-link class to Cite component and bibliography to Bibliography for custom styles. You can also create a higher-order-component to supply your custom class.

Writing bibliography

Article

There are many kind of scientific articles such as conference and journal articles.

{
    type: "article",
    title: "Literate Programming",
    authors: ["Donald E. Knuth"],
    year: 1984,
    journal: {
        name: "The Computer Journal",
        issue: 2,
        volume: 27,
        pages: [97, 111],
    },
    doi: "https://doi.org/10.1093/comjnl/27.2.97",
}

Book

{
    type: "book",
    title: "Structure and Interpretation of Computer Programs",
    authors: [
        "Harold Abelson",
        "Gerald Jay Sussman",
        "Julie Sussman"
    ],
    year: 1985,
    publisher: "MIT Press"
}

Websites

{
    type: "web",
    title: "TeX",
    authors: ["Wikipedia"],
    link: "https://en.wikipedia.org/wiki/TeX"
}

Citation Styles

There exists many academic citation styles such as IEEE. Different disciplines use different ones.

Default

The default style doesn't expect a scientific convention to be used, so a plain variation of ACM is used.

| Type | Bibliography | Citation | |---------|-----------------------------------------------------------------------------------------------------------------|------------| | Article | [1] John Doe. 2021. The Example Article. The Journal, Volume 1, Issue 3, Pages 1–10. DOI: https://doi.org/... | [1] | | Book | [2] Jane Doe. 2022. Example Book. Publisher. | [2, p. 20] | | Web | [3] Wikipedia. Node.js. https://en.wikipedia.org/wiki/Node.js. | [3] |

Custom

You can choose any supported style to render by passing the renderers or use a custom one e.g. if you have a custom style for _ACM, you would write

<CiteContextProvider citeFormatter={acmCiteFormatter} BibItemRenderer={ACMItemRenderer}/>

Item renderers must implement BibItemProps interface and cite formatters CiteFormatter interface, see the type definitions.