poppastring / dasblog-core

The original DasBlog reimagined with ASP.NET Core
MIT License
469 stars 193 forks source link

Optional embeddings in blog posts for bare links #677

Closed clemensv closed 1 year ago

clemensv commented 1 year ago

This PR adds three options for siteConfig (but does not touch the settings UI just yet):

  <EnableRewritingHashtagsToCategoryLinks>false</EnableRewritingHashtagsToCategoryLinks>
  <EnableRewritingBareLinksToEmbeddings>false</EnableRewritingBareLinksToEmbeddings>
  <EnableRewritingBareLinksToIcons>false</EnableRewritingBareLinksToIcons>

The generated Twitter Card and Open Graph embeddings use "opengraph-" prefixed CSS class names as can be seen with this example:

<div class="opengraph-preview">
    <div class="opengraph-preview-site">
          <a class="opengraph-preview-link"
            href="https://www.wsj.com/articles/tesla-stock-falls-more-than-12-posting-worst-drop-in-over-two-years-11672783776"><img
                class="opengraph-preview-site-icon" src="https://s.wsj.net/media/wsj_launcher-icon-0-75x.png"> The Wall
            Street Journal</a></div><a class="opengraph-preview-link"
        href="https://www.wsj.com/articles/tesla-stock-falls-more-than-12-posting-worst-drop-in-over-two-years-11672783776"><img
            class="opengraph-preview-image" src="https://images.wsj.net/im-696241/social">
        <div class="opengraph-preview-info">
            <h3 class="opengraph-preview-title">Tesla Stock Falls 12%, Posting Worst Drop in Over Two Years</h3>
            <p class="opengraph-preview-description">Wall Street resets 2023 vehicle-delivery expectations after last
                year’s numbers fell short.</p>
        </div>
    </a>
</div>

The implementation is done in a new service.

poppastring commented 1 year ago

@clemensv Will review and merge in a couple of days.

shanselman commented 1 year ago

Looks like this caches the emdeds at runtime but does the work every page view? So if you startup cold, you're gonna do some real work as each new page gets rendered, right? and it really needs caching to be on. Just checking that I understand it

poppastring commented 1 year ago

@clemensv 👍🏿