GithubHelp home page GithubHelp logo

Comments (2)

Mevrael avatar Mevrael commented on June 26, 2024

+1, same on Windows 10 for me. In any OS URLs should always have only forward slash "/". Anyway I don't see any advantages of using custom functions when you always can type path with leading slash "/assets/css/custom.css"

from markdown-styles.

gene-pavlovsky avatar gene-pavlovsky commented on June 26, 2024

@Mevrael relative paths can be useful when deploying files not in web server's root.
E.g. I'm working on http://www.example.com and deploying everything in it's root, but on my work computer I'm using a local web server and since I work on more than one website, my files reside are on http://localhost/www.example.com, using relative paths it works same on both my local dev server and on the production server.

Workaround - using a custom layout, added this helpers/asset.js:

var handlebars = require('handlebars');

module.exports = function(context, options) {
  var output = '';
  // data.root is the original item (e.g. the value from the stream)
  // it will have an assetsRelative path from the setOutputPath function
  output += options.data.root.assetsRelative + '/';
  // Get rid of any leading slash on the context
  context = context.replace(/^\//, '');
  output += context;

  return new handlebars.SafeString(output.replace(/\\/g, '/'));
};

The output.replace(...) in the last line changes all backslashes to forward slashes.

from markdown-styles.

Related Issues (20)

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.