jekyll / jekyll-mentions

:busts_in_silhouette: @mention support for your Jekyll site
http://rubygems.org/gems/jekyll-mentions
MIT License
198 stars 30 forks source link

Add a mechanism for disabling @mentions on a page #39

Open bkeepers opened 8 years ago

bkeepers commented 8 years ago

I'm following the Jekyll search using lunr.js guide, and one step involves outputting JSON on the page:

…
<script>
  window.store = {
    {% for post in site.posts %}
      "{{ post.url | slugify }}": {
        "title": "{{ post.title | xml_escape }}",
        "author": "{{ post.author | xml_escape }}",
        "category": "{{ post.category | xml_escape }}",
        "content": {{ post.content | strip_html | strip_newlines | jsonify }},
        "url": "{{ post.url | xml_escape }}"
      }
      {% unless forloop.last %},{% endunless %}
    {% endfor %}
  };
</script>
…

This works fine, except that the jekyll-mentions plugin still finds @mentions in content and autolinks them, which then breaks the json.

For this specific use case, one solution is to move just the json to a separate file called content.json, since jekyll-mentions only operates on html pages.

Are there other uses cases though where it might make sense to allow disabling @mentions per-page?

benbalter commented 8 years ago

This works fine, except that the jekyll-mentions plugin still finds @mentions in content and autolinks them, which then breaks the json.

Is it linking the mention once it's been jsonified, or the content when it renders the underlying post?

For this specific use case, one solution is to move just the json to a separate file called content.json, since jekyll-mentions only operates on html pages.

Exactly what I was going to suggest.

bradjc commented 7 years ago

Are there other uses cases though where it might make sense to allow disabling @mentions per-page?

Yes and no. The case is if you include CSS in a page and it has an @media attribute. However, disabling in this case absolutely makes sense.

mbirth commented 7 years ago

I'd prefer a way to prevent single @… statements from being linked, e.g. by escaping the @ like in \@something. This is how it works for other markdown, too.

See also: jch/html-pipeline#232 and jch/html-pipeline#250

parkr commented 6 years ago

I'm wholly 👍 to the idea of a front-matter option like jekyll-mentions: disable or jekyll-mentions: false or disable_plugins: [jekyll-mentions] on a per-page/per-document basis.

emmahsax commented 4 years ago

Also, would be super nice if you could override the base_url for a single file, such as

jekyll-mentions: https://twitter.com

in your _config.yml, but

jekyll-mentions: https://github.com

for a different file to use that base_url.


I made a fork of this gem, and made both of the changes discussed here: https://github.com/emma-sax4/jekyll-mentions.

So, we can override the base_url in each specific page/post frontmatter. Or, we can disable mentioning on a specific page/post by specifying false:

jekyll-mentions: false

It can be included by specifying this in the Gemfile:

gem 'jekyll-mentions', :git => 'https://github.com/emma-sax4/jekyll-mentions.git'
ashmaroli commented 4 years ago

@bkeepers I would like to inform you that this feature has landed on the master!! :tada: :sparkles: If you're still using this plugin, do let us know if it works for your use-case. Thanks.