Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Markdown format & styling #1

Open
airjoshb opened this issue Aug 9, 2016 · 3 comments
Open

Markdown format & styling #1

airjoshb opened this issue Aug 9, 2016 · 3 comments

Comments

@airjoshb
Copy link

airjoshb commented Aug 9, 2016

I am a bit confused about how to get the markdown format for body to work and how to make styles for each heading. The text comes in all as the default and ignores the markdown.

Here are examples:

document.components << AppleNews::Component::Body.new(text: self.body, format: "markdown")
and
document.components << AppleNews::Component::Heading.new(text: self.title, role: :heading1, text_style: { font_name: 'AvenirNext-Bold', font_size: 14 })

Thank you

@meltingice
Copy link
Contributor

The code looks fine from what I can tell. Can you validate that the generated JSON matches what you expected? You can get it by running document.as_json.

@airjoshb
Copy link
Author

Thanks for the .as_json tip- with it I was able to parse out pretty much what I needed. I was never able to get the inline styles to work, but I was able to reference a "style" defined in the Default styles that gave me the control I was looking for.

I have gotten one more hitch in trying to build a header component which has a layout, style and components that make it up. I am able to get the correct json output for the first two, but it will not recognize the components. Here is a simple version of the code:
document.components << AppleNews::Component::Header.new( layout: { column_start: 0, column_span: 7, ignore_document_margin: true, minimum_height: "65vh" }, style: { fill: { type: :image, url: self.image.hero.url } }, components: [ { role: :byline, text_style: :subtitle, text: self.subhead.squish } ])

which comes up

"components"=>[{"role"=>"header", "layout"=>{"column_start"=>0, "column_span"=>7, "ignore_document_margin"=>true, "minimum_height"=>"65vh"}, "style"=>{"fill"=>{"type"=>"image", "url"=>"https://stepone-scd.s3-us-west-1.amazonaws.com/uploads/article/image/300/hero_Halloween_party_with_The_Troubs_at_Kuumbwa_Jazz.jpg"}}, "components"=>[nil]}

I have tried every way I can think of to write it out and the only way I can get components to show is if I do
components: [1,2,3]
or
components: { role: :byline, text_style: :subtitle, text: self.subhead.squish }

which gives the predictable

"components"=>[["role", "byline"], ["text_style", "subtitle"], ["text", " Presented by Kuumbwa Jazz]]

Thanks again

@airjoshb
Copy link
Author

Any thoughts on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants