baranovskypd / goodpress

WIP!! :warning: R Package to Write Posts from R Markdown to Wordpress :warning:
https://maelle.github.io/goodpress/
Other
34 stars 5 forks source link

Read More Separator #18

Closed henrywangnl closed 3 years ago

henrywangnl commented 4 years ago

Hi Maëlle,

Do you know if I can have a read more separator in R Markdown? I don't want to show the whole post on my homepage.

Thanks

maelle commented 4 years ago

Can you try adding

```{=html}
<!-- wp:more -->
<!--more-->
<!-- /wp:more -->


or whatever the html is in your current posts (view source) that allows to get the read more.
henrywangnl commented 4 years ago

yes, it works! Thanks!

maelle commented 4 years ago

Cool. If you want to make a PR to add that to the goodpress.Rmd, you're welcome to do that 🙂

maelle commented 4 years ago

Would it make sense to create a function goodpress::read_more() so one would add in index.Rmd

`r goodpress::read_more()`

Instead of remembering the syntax? It would produce the right lines in index.md

henrywangnl commented 4 years ago

That's be nice. Also, I notice that you have a Wordpress Document template, which I think is a good idea to include more information. For example, the YAML header could be more specific. This issue can also be included. Plus, how to publish the post. Now I'm maintaining a separate R file includes:

library(goodpress)

post_folder <- "/Users/henry/R/Blog/20200625"
wordpress_url <- "https://henrywang.nl"

wp_post(post_folder, wordpress_url)

Hope it can give some hints.

maelle commented 4 years ago

What template are you referring to?

henrywangnl commented 4 years ago

henrywangnl commented 4 years ago

Cool. If you want to make a PR to add that to the goodpress.Rmd, you're welcome to do that 🙂

Sure, I would like to do it!

maelle commented 4 years ago

oh right I started creating one! I should improve it, thanks.

Do you also want to create the function goodpress::read_more()? It'd output text. Then the docs would mention it.

henrywangnl commented 4 years ago

Not sure if I can do it. I would like to try it!

maelle commented 4 years ago

I can help, tell me what you (don't) know and I can provide links/tips in a couple of hours when I'm back at my desk. :-)

maelle commented 4 years ago

Thanks for the docs PR!

For adding a function I'd recommend

read_more <- function() {
  paste(
    "```{=html}",
    "<!-- wp:more -->",
    "<!--more-->",
    "<!-- /wp:more -->",
    "```",
    sep = "\n"
 )
}
henrywangnl commented 4 years ago

Thanks! I will check it later. Never contribute to other packages before haha!

maelle commented 4 years ago

:grinning:

henrywangnl commented 4 years ago
  • try the function in an Rmd.

Hi Maelle,

I'm in this step and I called the function like this: goodpress::read_more()

The knitted output is a string like <!-- wp:more -->\n<!--more-->\n<!-- /wp:more -->

But I don't know how to control it is rendered as HTML tag instead of such a string.

Do you have any idea?

maelle commented 4 years ago

Yes either use it inline or in a chunk with results='asis' (or is it result, not results?)

I can look more into it tomorrow.

maelle commented 3 years ago

have you tried using a chunk with results="asis" or to use it in inline code?

henrywangnl commented 3 years ago

yes, you are right. The inline code of r goodpress::read_more() works! I can add it for the next PR. Thanks!

maelle commented 3 years ago

yay :tada: