GithubHelp home page GithubHelp logo

cwaring / vuepress-plugin-ipfs Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 1.0 39 KB

Host any VuePress project on IPFS

License: MIT License

JavaScript 100.00%
vuepress vuepress-plugin-ipfs vuepress-plugin ipfs ipfs-gateway

vuepress-plugin-ipfs's Introduction

VuePress Plugin IPFS

Convert a VuePress 1.x bundle into relative paths making it suitable for hosting on IPFS.

Usage

npm i -D vuepress-plugin-ipfs

Setup

Add to config.js or theme/index.js

module.exports = {
  plugins: [
    ['vuepress-plugin-ipfs'],
  ]
}

Once included this this plugin will post process all generated pages and CSS files to use relative asset paths during a production build.

$withBase - Base URL helper

Sites hosted on IPFS will be accessed via a variable depth so it is important to use relative paths for assets wherever possible, however there are certain scenarios where this is not viable due to components being included on multiple pages (such as headers/footers) or when asset paths are programmatically included.

If your site is accessed via an IPFS gateway the base path will be computed to include the current IPFS gateway and CID. For example, https://gateway.ipfs.io/ipfs/<CID>/, then base will be configured to "/ipfs/<CID>/". The same goes for any IPNS gateway paths.

Therefore it is best to use this built in helper method to wrap asset paths. $withBase (injected onto Vue’s prototype) to generate the correct path when accessed via the root domain or IPFS gateway:

<img :src="$withBase('/foo.png')" alt="foo">

Tip: You can use the above syntax in theme components and Markdown files.

💡If you have a base key set in .vuepress/config.js or theme/index.js you will need to remove it in order for this plugin to work correctly.

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.