deprecated-packages / symplify

[DISCONTINUED] Check split packages in their own repositories :)
MIT License
621 stars 189 forks source link

Statie: Lack of perex and feed #1588

Closed dsas closed 5 years ago

dsas commented 5 years ago

This is more of a question than an issue. I want my blog to have an rss feed. I tried to do this by:

{% for post in posts|slice(0,10) %}
      <item>
        <title>{{ post.title | xml_escape }}</title>
        <description>{{ post.content | xml_escape }}</description>
        <pubDate>{{ post.getDateInFormat('r') }}</pubDate>
        <link>{{ site.url }}{{ post|link }}</link>
        <guid isPermaLink="true">{{ site.url }}{{ post|link }}</guid>
      </item>
    {% endfor %}

However by the time this is being rendered post.content is actually the html for the entire post webpage rather than just the contents of the post (i.e. the html conversion of my markdown file). It appears that Statie just keeps replacing the content in place as it generates the page

I see some other people using statie have avoided this issue by using a "perex" in their frontmatter and including that, I'd rather not have to go and add that to each of my posts by hand though.

Do you have any suggestions?

TomasVotruba commented 5 years ago

Hi, the content is in the HTML form by design.

So you need the HTML to be text back again?

I use strip tags, see my website rss: https://github.com/TomasVotruba/tomasvotruba.cz/blob/master/source/rss.twig

dsas commented 5 years ago

Ideally I'd have the HTML as text again, yes. Given that post.content is a complete HTML document with title and site navigation and so forth, then just strip tagging won't work as I'll get the contents of the title element and so forth.

Perhaps I need to generate a post.perex, either automatically or as a one-off.

TomasVotruba commented 5 years ago

If you want to add content_raw property to the post object in PR, I'll guide you.

dsas commented 5 years ago

Is it necessary? AbstractGeneratorFile already has rawContent / getRawContent which is the markdown content converted to HTML and then strip tagged. I can then just use post.rawcontent in my twig file.

Perhaps I'm missing something or you prefer content_raw, I'm happy to help :)

TomasVotruba commented 5 years ago

Well, have you tried it?

dsas commented 5 years ago

Sorry, yes I gave it a quick try and seems to be fine.