Git Product home page Git Product logo

Comments (22)

eduardoboucas avatar eduardoboucas commented on June 1, 2024 2

Thanks! I'm glad you find it useful.

That's a very interesting idea. What you need is effectively a way of outputting a Markdown file with the front-matter format used by Jekyll to create a post (which is effectively Markdown), as well as the post body.

The first option that comes to mind is to add a new output format (called post perhaps), as well as a new transform type (called post-body).

Form example:

<input type="hidden" name="fields[category]" value="music">
<input type="text" name="fields[title]">
<textarea name="fields[body]"></textarea>

Staticman config:

format: 'post'
transforms:
  body: 'post-body' # This will tell Staticman that this field is the post body

Output:

category: "music"
title: "Whatever is typed into title"
---
Whatever is typed into the post body. It can have Markdown or HTML, Staticman doesn't care

Does that make sense?

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024 2

I was finally able to look at this (sorry I took ages). I've pushed this feature to a new test instance. Here's how you can use it:

  1. Add the following to your config, where yourContentField is the name of the field you want to use as the post body

    format: "frontmatter"
    transforms:
      yourContentField: "frontmatterContent"
  2. Change your Staticman URL from https://api.staticman.net to https://dev.staticman.net.

It's a test instance, so it might be a bit slow. Can you give it a test, see if it does what you're after and let me know of any issues?

Thanks!

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024 2

Great! 🎉

Closing.

from staticman.

thierrybgentile avatar thierrybgentile commented on June 1, 2024 1

@eduardoboucas I will at some point this week! I'll get back soon.

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024 1

Added in #41.

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024 1

Thanks, I'll look into this.

from staticman.

lisandroct avatar lisandroct commented on June 1, 2024 1

Since markdown files are not allowed as data files, a possibility is to "markdownify" a value of the yaml output: {{value | markdownify}}. 👌

from staticman.

thierrybgentile avatar thierrybgentile commented on June 1, 2024

Yes it does make sense. That would be really great.

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024

I'm think it would be useful to spin up a test instance of the Staticman API (on a free Heroku instance) to test new features. Would you be able to assist with test driving this once I implement?

from staticman.

thierrybgentile avatar thierrybgentile commented on June 1, 2024

I'll do my best! I don't know much about testing but I'll look it up and test as much stuff as I can with my little prototype.

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024

@thierrybgentile let me know if you get the chance to test this.

from staticman.

ctrl-b avatar ctrl-b commented on June 1, 2024

Is the frontmatterContent transformation working from api.staticman? I tested on dev.staticman and it is working but on api (master) it is not, it returns undefinied, thanks

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024

@usrix It should be, yes. There should be no differences between the two at the moment. What are you getting back?

from staticman.

ctrl-b avatar ctrl-b commented on June 1, 2024

@eduardoboucas

Using api.staticman I get undefined in the markdown body

YAML block:

---
fieldone: field text
fieldname: field name text
---
undefined

Using dev.staticman

I get:

---
fieldone: field text
---

field name text

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024

@usrix I just redeployed. Could you try again, please?

from staticman.

ctrl-b avatar ctrl-b commented on June 1, 2024

@eduardoboucas, I did a few tests and it is working now! 👍

from staticman.

ctrl-b avatar ctrl-b commented on June 1, 2024

hey @eduardoboucas

After testing different scenarios, one came out, when the frontmatter field is not required (optional) and is not sent to staticman, the markdown part is generated as "undefined", I think it would be better to skip it on those cases

from staticman.

ctrl-b avatar ctrl-b commented on June 1, 2024

@eduardoboucas

I'm having the same issue than last time,

api.staticman

is displaying the "frontmatterContent" in the yaml block and the markdown body undefined

dev.staticman

Is working correctly

from staticman.

SidVal avatar SidVal commented on June 1, 2024

Same here.
I could not send the data to the body post 😭
Related: #91

from staticman.

lisandroct avatar lisandroct commented on June 1, 2024

Same here. dev.staticman.net works just fine but I got "undefined" whenever I use api.staticman.net.

This is a really cool feature! 😃

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024

I’m sorry that this has been an issue for so long. I’ll try to sort it in the next couple of days.

from staticman.

eduardoboucas avatar eduardoboucas commented on June 1, 2024

(Moving the discussion to #91)

from staticman.

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.