Giter VIP home page Giter VIP logo

pagine's Introduction

pagine's People

Contributors

johnsylvain avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

pzzazz vaginessa

pagine's Issues

Markdown files should be fetched via http

Users should be able to pass in the location of the markdown file into the constructor function and have the content be loaded by an ajax call.

Current Behavior
Markdown content has to be typed directly into new Pagine({ ... }) call.

new Pagine({
// ...
  md: '# markdown' // markdown has to be added here as a string
// ...
});

New Behavior
Users should only have to place the markdown file's relative url into the constructor function.

new Pagine({
// ...
  md: './path/to/markdown.md' // markdown path
// ...
});

Cache compiled html templates

Current behavior
Markdown has to be transformed to HTML on every route change

Expected behavior
Compiled HTML should be cached in an Object and checked before compiling Markdown.

this.cache = {
  md: {}, // markdown cache
  html: {
    '/': '<div></div>',
    '/about': '<div>About</div>'
  }
}

Update README to reflect new API design

The usage section of the README needs to be updated. The new api design looks like the snippet below.

JavaScript

import Pagine from 'pagine';

new Pagine({
  view: '#view',
  routes: [
    {
      path: '/home',
      md: './markdown/home.md',
      layout: '#main'
    }
  ]
})

HTML

<div id="view"></div>
<script type="text/html" id="main">
  <%= content %>
</script>

Replace Navigo

Replace Navigo with a vanilla JavaScript router. While Navigo provides many useful features, it is not entirely necessary for this project.

A much smaller implementation can be created that accomplishes the same goal.

Remove webpack

Change module bundler from Webpack to Rollup for more performant bundles.

Fix testing for route changes

Testing (via jest) is currently broken for checking route changes. We should be able to test content is being rendered properly when routes change.

/*
* TODO: Fix this unit test to change URL location
*/
it('should change view content on route change', () => {
var output;
window.location.url = '#/home';
output = $('#view').first().innerHTML.trim()
expect(output).toBe('<h2>home page</h2>');
window.location.url = '#/about';
output = $('#view').first().innerHTML.trim()
expect(output).toBe('<h2>about page</h2>')
});

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.