Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown provider: Pass path & file info #139

Closed
abovedave opened this issue Mar 27, 2017 · 1 comment
Closed

Markdown provider: Pass path & file info #139

abovedave opened this issue Mar 27, 2017 · 1 comment

Comments

@abovedave
Copy link
Contributor

abovedave commented Mar 27, 2017

Would be handy to pass info about the file to the JSON for use in the front end. For example, path and filename.

/posts/setup/testing.md

{
        "original": "---\ndate: 2016-04-17\ntitle: Testing\nhandle: pages\nauthor: The DADI Team\n---\n\nhow to create a new page...",
        "attributes": {
          "date": "2016-04-17T00:00:00.000Z",
          "title": "Testing",
          "author": "The DADI Team"
        },
        "path": [
          "posts",
          "setup"
        ],
        "filename": "testing",
        "contentText": "how to create a new page...",
        "contentHtml": "<p>how to create a new page...</p>\n"
}
abovedave pushed a commit that referenced this issue Mar 31, 2017
@abovedave
Copy link
Contributor Author

abovedave commented Mar 31, 2017

Ok, I've noticed we don't actually support a nested directory structure, so I will add that in. [ed: now done]

From my last commit, I've added some additional values to the attributes object:

"attributes": {
  "date": "2016-05-10T00:00:00.000Z",
  "title": "Test folder reader",
  "author": "The DADI Team",
  "_loc": "workspace/posts/folder/filename.md",
  "_ext": ".md",
  "_id": "filename",
  "_path": [
    "workspace",
    "posts",
    "folder"
  ]
}

I noticed if you added a non-text file into the file directory, it caused an error (e.g., an image). I've added support for an extension parameter which will only look for files with the given extension (the default being .md files). The datasource schema looks like:

{
  "datasource": {
    "key": "posts",
    "name": "Blog posts as markdown files.",
    "source": {
      "type": "markdown",
      "path": "./workspace/posts",
      "extension": "txt"
    }
}

abovedave pushed a commit that referenced this issue Mar 31, 2017
abovedave pushed a commit that referenced this issue Apr 3, 2017
abovedave pushed a commit that referenced this issue Apr 3, 2017
abovedave pushed a commit that referenced this issue Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant