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

eleventy-plugin-org

v1.2.0

Published

Eleventy plugin to generate posts from org-mode files

Downloads

9

Readme

Eleventy org-mode plugin

typescript-image npm-image license-image

This plugin lets you pull your org notes into eleventy data for further processing.

Highlights

  • handles org id links and translates them to relative file links
  • calculates backlinks for notes
  • handles images linked in notes
  • extracts tags assigned in org mode
  • compatible with org-roam

Setup

Install the plugin:

npm install eleventy-plugin-org

Add it to your eleventy config. There is one required configuration option: orgDir which should point to folder with your org files.

const pluginOrg = require("eleventy-plugin-org");

module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(pluginOrg, { orgDir: "~/org-notes/" });
};

Configuration options

  • orgDir - folder with org files
  • blogTag - (default: null) optionally can filter notes to those having specific org tags, can be a string or array of strings
  • excludeTags - (default: null) an array of tags - notes with that tags will be filtered out of the final collection
  • noexportCheck - (default: true) whether to automatically filter out notes with nooexport tag (default org-mode tag for (wait for it) disabling export)
  • collectionName - (default: "org") name of the eleventy collection that org files will be assigned to
  • imageFolder - (default: "org-images") name of the folder to copy images from org notes

Usage

After setting everything up plugin will create a new eleventy collection with data representing your org notes. By default this collection is named org.

The data structure for each note is following:

interface Note {
  title: string; // Note title
  slug: string; // Note slug derived from file name
  content: string; // Html content of the note
  tags: string[]; // File tags
  date: string // Eleventy compatible date in format 'YYYY-MM-DD'
  data: {
    links: Set<string>; // Set of links coming from that page
    backlinks: Map<string, { slug: string, title: string } // Map of backlinks for given note
    // all of the keywords parsed from org file header
  }
}

You can generate files from the data by using eleventy paging feature eg.:

---
pagination:
    data: collections.org
    size: 1
    alias: post
	addAllPagesToCollections: true
permalink: "{{ post.data.slug }}/"
---
<!DOCTYPE html>
<html>
  <body>
  ...
    <h1>{{ post.title }}</h1>

    {{ post.content | raw }}
  ...
  </body>
</html>

Unfortunately at this point in time eleventy does not support setting tags while dynamically creating the pages, so you can't use collection.tagName to get the org mode pages tagged with tagName. Because of that there is a second collection created by suffixing base collection with Tags (so orgTags by default). Each element in tags collection nas tagName and posts fields.

Using this collection you can create tag pages eg.

---
pagination:
  data: collections.orgTags
  size: 1
  alias: tag
permalink: /tags/{{ tag.tagName }}/
eleventyComputed:
  title: Tagged {{ tag.tagName }}
---
...
{% for post in tag.posts %}
<li><a href="{{post.data.slug}}">{{ post.data.title }}</a></li>
{% endfor %}
...

You can find more complete example in example folder

Inspiration

Thanks to uniorg library for providing a great way to parse and work with org-mode files. Base of this plugin has been extracted from one of the examples supplied by uniorg