Git Product home page Git Product logo

filestojson's People

Contributors

bernardodiasc avatar rmariuzzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rmariuzzo

filestojson's Issues

Split output into multiple files

Actual

Currently the script will generate a single JSON file.

Expected

The way the output files will be created need to be configurable. One simple use case is to have a single JSON for each content type, but this could be even more flexible.

Copy public files along with JSON output

Actual

Image files are stored together with content files, as they are content as well. The problem is that the content path is not public, therefore images aren't be accessible.

Expected

Images should be copied to a public place respecting original path structures from contents. This step need to be together with the data generation.

Improve content type translation functions

For each Content Type there is a translation file that return the custom structured data based on an index of files of that kind.

Actual

content type from examples in this repo

// posts.js
function translation (content, contentType) {
  let output = {}
  const allFiles = content.filter(each => each.dir.includes(`/${contentType}`))
  const index = allFiles.filter(each => each.base === 'index.md')[0]
  index.attr.forEach(each => {
    allFiles.forEach(file => {
      if (file.name === each) {
        output[each] = file
      }
    })
  })
  return output
}

export default translation
// gallery.js
function translation (content, contentType) {
  let output = {}
  const allFiles = content.filter(each => each.dir.includes(`/${contentType}`))
  const index = allFiles.filter(each => each.base === 'index.md')[0]
  index.attr.forEach(each => {
    Object.keys(each).forEach(key => {
      output[key] = Object.assign({ title: each[key] }, allFiles.filter(file => file.name === key)[0])
    })
  })
  return output
}

export default translation

Expected

psedo-code bellow demonstrate what is the translation for each content type, the rest should be abstracted away to keep theses translations as simple as possible.

// posts.js
  index.attr.forEach(each => {
    allFiles.forEach(file => {
      if (file.name === each) {
        output[each] = file
      }
    })
  })
// gallery.js
  index.attr.forEach(each => {
    Object.keys(each).forEach(key => {
      output[key] = Object.assign({ title: each[key] }, allFiles.filter(file => file.name === key)[0])
    })
  })

Config path argument aren't working

Actual

When running filestojson ./tests/fixtures/config.js, the config path is just a string and is also a relative path.

Expected

The config path argument need to return the actual config module.

Preview output

User story

As a developer, while editing existing or creating a new content type, I want to quickly preview that specific content type data structure on console in order to have simpler development experience.

Expected

  1. create new content type, as ./contents/posts
  2. create index and a sample post, respectively ./contents/posts/index.md and ./contents/posts/post-1.md
  3. include post-1 key/value in Posts Index:
---
- post-1: Post 1
---
  1. include Post 1 content:
---
- title: Post 1
---

This is a sample post.

## Featuring Markdown

> actually Front-matter

- n
- i
- c
- e
  1. [complicated configuration part here, depends on: #4 and #6]
  2. run command filestojson --preview ./content/posts (depends on #2) and get on console:
# Posts content type

"posts": {
  "post-1": {
    "file": "/posts/post-1.md",
    "dir": "/posts/post-1",
    "name": "post-1",
    "base": "post-1.md",
    "ext": ".md",
    "attr": {
      "title":"Post 1",
    },
    "body": "This is a sample post.\n\n## Featuring Markdown\n\n> actually Front-matter\n\n- n\n- i\n- c\n- e\n"
  }
}

Support more file types

Actual

Currently only supporting .md and .png.

Expected

Support more textual types, more image types and maybe allow to include code types too (not to run the source code, but as a source of content, with proper treatment).

Configuration contentTypes validation need detailed shape

Currently the contentTypes validation are limited to an array of object. It should define better the object shape.

Actual

contentTypes: Joi.array().min(1).items(Joi.object()).required(),

Expected

Example:

contentTypes: Joi.array().min(1).items(
  Joi.object({
    arg: Joi.string().required(),
    value: Joi.func().required(),
  })
).required(),

The problem with the snippet above is that is not valid for the need, using it just as pseudo-code.

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.