Giter VIP home page Giter VIP logo

eleventy-plugin-backlinks's Introduction

Eleventy-Plugin Backlinks

Collect and display backlinks from your notes.

NPM version badge

Note: I'm not building this project for myself, so y'all gotta tell me what you think. Issues are the way to go here.

Usage

Add the plugin to your eleventy config, like so:

const eleventyBacklinks = require("eleventy-plugin-backlinks");

module.exports = function(eleventyConfig) {
    eleventyConfig.addPlugin(eleventyBacklinks, {
		folder: '/notes' // The folder with your notes
    });
}

For every page in the given folder, you get a backlinks variable. By default, it contains an array, with the title (if set) and the url of each page.

Options

  • folder (string) - The name of a folder which contains your notes. The default folder-name is "notes".
  • getData (function) - Optionally, control which data will be passed to backlinks. The function receives a collection item, and is called for every relevant page.

Contributing

All input is welcome; feel free to open an issue. Please remember to be a mensch. If you want to program, you can browse the issue list.

Legal

All source-code is provided under the terms of the MIT license. Copyright 2022 Binyamin Aron Green.

eleventy-plugin-backlinks's People

Contributors

binyamin avatar ebiyu avatar jacobbudin avatar xplosionmind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eleventy-plugin-backlinks's Issues

Handling eleventy config dir.input

In my eleventy configuration, I have:

return {
  dir: {
    input: "notes"
  }
}

I'm not sure what I need to set the folder parameter to be for this plugin.

Thanks

config.addcollection(notes) already exist

Hi, following my question in your theme project eleventy-garden, I tried your plugin and got an error :

[11ty] 1. Error processing the `BacklinksPlugin` plugin (via EleventyPluginError)
[11ty] 2. config.addCollection(notes) already exists. Try a different name for your collection. (via UserConfigError)

My steps

  1. I added your plugin in my .eleventy.js :
const eleventyBacklinks = require('eleventy-plugin-backlinks');

module.exports = function(eleventyConfig) {
	
  // plugin to add backlinks
  eleventyConfig.addPlugin(eleventyBacklinks, {
		folder: '/notes', // The folder with your notes
                getData: 'description'
    });
[]
}
  1. I installed the plugin with npm install eleventy-plugin-backlinks
  2. I commented notes.11tydata.js to avoid conflicts
  3. In the include backlinks.html, I tried to get the description passed through with getData ?
<hr>
<p class="larger" lang="en">
  Backlinks
</p>
{%- if backlinks.length > 0 -%}
<ul class="backlink">
  {%- for link in backlinks -%}
    <li class="backlink-note">
      <a href="{{- link.url -}}">
        <span class="larger">{{- link.title -}}</span>
          {{- link.preview | markdownify -}}
      </a>
    </li>
  {%- endfor -%}
</ul>
{%- else -%}
<p>
  Aucun <span lang="en">backlink</span> trouvé !
</p>
{%- endif -%}

And I got the collection error. Does your code is adding a collection note by itself then ?
How do we do to resolve this collection conflict ?

My .eleventy.js is indeed adding a collection, I don’t know if it’s your theme or the code I picked elswhere, but I’m pretty sure it’s needed elswhere in the code :

  eleventyConfig.addCollection("notes", function (collection) {
    return collection.getFilteredByGlob(["notes/*.md", "notes/Journal/*.md", "notes/Fakes/*.md"])
    .sort((a, b) => b.data.date - a.data.date);
  });

If I comment the collection code, I get another error linked to your plugin : 

[11ty] options.getData is not a function (via TypeError)

Do I have to declare a getData function by myself to get the note.description I just want to get ?

Again, sorry for being such a newbie, I don’t understand js very well when it’s at this scope u_u

Thanks in advance,

Yazae

Markdown support?

Are you planning to support not only wikilinks but also simple markdown links?

I implemented prototype of markdown support.
If you are willing to add markdown support, I will create pull-request and I want to ask something to decide specifications.

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.