Coder Social home page Coder Social logo

ahmadnassri / node-metalsmith-paths Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 7.0 438 KB

Metalsmith plugin that adds file path values to metadata

Home Page: https://www.npmjs.com/package/metalsmith-paths

License: MIT License

JavaScript 85.71% Makefile 14.29%
node metalsmith lib

node-metalsmith-paths's Introduction

Metalsmith Paths

A Metalsmith plugin that adds file path values (base, dir, ext, name, href) to metadata path property.

license release semantic

Install

npm install metalsmith-paths

API

const metalsmith = new Metalsmith(__dirname)
  .use(paths({
    property: "paths"
  }))

given the following directory structure:

src/
└── blog
    └── post.html

The following metadata will be generated:

metadata value
path.base post.html
path.dir blog
path.ext .html
path.name post
path.href /blog/post.html
path.dhref /blog/

CLI

You can also use the plugin with the Metalsmith CLI by adding a key to your metalsmith.json file:

{
  "plugins": {
    "metalsmith-paths": {
      "property": "paths"
    }
  }
}

Options

name description default
property property to store the path data to path
directoryIndex remove the filename if it matches disabled
winToUnix exchange \ for / on Windows true

directoryIndex

Removes the filename from the href attribute if it matches the value of directoryIndex. Default: disabled. For example, the following configuration:

{
  "plugins": {
    "metalsmith-paths": {
      "property": "path",
      "directoryIndex": "index.html"
    }
  }
}

Would produce the following filenames:

Filename path.href
/index.html /
/portfolio/index.html /portfolio/
/portfolio/project1.html /portfolio/project1.html
/portfolio/project2.html /portfolio/project2.html

Author: Ahmad Nassri • Twitter: @AhmadNassri

node-metalsmith-paths's People

Stargazers

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

Watchers

 avatar  avatar  avatar

node-metalsmith-paths's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Cannot push to the Git repository.

semantic-release cannot push the version tag to the branch master on the remote Git repository with URL https://github.com/ahmadnassri/node-metalsmith-paths.git.

This can be caused by:


Good luck with your project ✨

Your semantic-release bot 📦🚀

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:angularmaterial). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

New version (2.1.2)

With the directoryIndex pull request added, could we please update the version number to 2.1.2?

On windows, backslash instead of forwardslash in directory string

Hello!

On windows, there is a problem with directory string because contains backslash instead of forward slash.
Error example:
paths.dir maindir\subdir
paths.href /maindir\subdir/index.html
paths.dhref /maindir\subdir/

It should be:
paths.dir maindir/subdir
paths.href /maindir/subdir/index.html
paths.dhref /maindir/subdir/

Conflict with metalsmith-permalinks?

Hi there,

Thank you for this plugin. I've tried to use it but it seems to conflict with metalsmith-permalinks.

Unless I'm missing something, both seem to use the path property, so the path gets overwritten when the paths plugin runs before the permalinks plugin.

Can you confirm this issue? If so, would it make sense to rename the property to avoid the conflict? I'm using this method as a workaround on my local version, but it would be nice to do it in the repository.

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.