Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add programatic way to specify pull quotes #4

Open
bcoe opened this issue Apr 19, 2015 · 2 comments
Open

add programatic way to specify pull quotes #4

bcoe opened this issue Apr 19, 2015 · 2 comments

Comments

@bcoe
Copy link
Contributor

bcoe commented Apr 19, 2015

Based on @jameswomack's suggestion, it would be slick if we could programmatically specify pull quotes.

@jameswomack
Copy link

Some version of the below could be adapted to suit our needs.

// Forgoing jQuery, using https://gist.github.com/jameswomack/d3b536298687e3264810

var articles = $('[itemprop=articleBody]');
articles.forEach(function pullQuotesInArticle(article){
  // Linguistic analysis could be used to forgo placeholders
  // but this solution is more flexible in terms of design
  var placeholderEls = article.$('section[for=pullquote]');
  var placeHolderCount = placeholderEls.length;

  // Only pull as many quotes as there are placeholders
  var quoteEls = article.$('[data-pullquote]').slice(0, placeHolderCount);
  quoteEls.forEach(function(quoteEl, index){
    placeholderEls[index].appendChild(quoteEl);
  });
});
<div itemprop="articleBody" class="article-body">
<section for="pullquote"></section><!-- a pullquote placeholder -->
<p><span data-pullquote>Polyglot Weekly grows from the question, <em>"what would get me blogging more often?"</em></span>I came up with a list of answers:</p> ...
<p>I can't wait to see what comes of this,</p>
<p>— Ben.</p>
</div>

@bcoe
Copy link
Contributor Author

bcoe commented Apr 20, 2015

I like the simplicity of simply having a pull-quote section.

We could use cheerio to populate the sections prior to writing the article to disk:

https://github.com/polyglotweekly/articleify/blob/master/lib/article.js#L104

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

No branches or pull requests

2 participants