schnack icon indicating copy to clipboard operation
schnack copied to clipboard

Slack %SLUG%

Open ghost opened this issue 7 years ago • 3 comments

slack.js: const post_url = config.get('page_url').replace('%SLUG%', event.slug)+'#comment-'+event.id;

page_url: "page_url": "https://example.com/%SLUG%",

In blogpost:

<h1 id="try-schnack">
<a class="anchor" href="#try-schnack">
 Try schnack</a>
 </h1>
<div class="comments-go-here"></div>
<% var title = post.title %>
<% var slug = post.slug %>
<% var sluglink = [title,slug].join('+++++') %>
<script type="text/javascript"
    src="https://schnack.example.com/embed.js" 
	data-schnack-slug="<%= sluglink %>"
    data-schnack-target=".comments-go-here">
</script>

This all works. But I need output following: title/slug and NOT title+++++slug

If I do .join('/') then schnack does not work at all, it fully crashes. I need the slash / as separator between title and slug.

How to fix?

ghost avatar Jul 12 '18 14:07 ghost

So the idea behind the slug was that you use the part of your blog post urls that is different for every post.

let's say your blog urls look like this:

https://mysite.com/blog/2018-11/this-is-a-post.html https://mysite.com/blog/2018-10/another-post-right-here.html https://mysite.com/blog/2017-04/a-really-old-post.html

then the url schema can be described as:

https://mysite.com/blog/ + slug + .html

and the slugs would be 2018-11/this-is-a-post, 2018-10/another-post-right-here and 2017-04/a-really-old-post.

in this scenario you'd set the page_url schnack config to be

{
   "page_url": "https://mysite.com/blog/%SLUG%.html"
}

and it should all work with slack.

gka avatar Nov 25 '18 18:11 gka

closing this for now

gka avatar Nov 28 '18 01:11 gka

There is more to this. The "/" in the slug causes a problem. See:

https://schnick.schnack.cool/comments/post-slug -> returns 200
https://schnick.schnack.cool/comments/post/slug -> returns 404

To solve this I had to escape the "/" in the form of "post%2Fslug" and configure my webserver to allow escaped slashes so that:

https://schnick.schnack.cool/comments/post%2Fslug returns 200

kon-foo avatar Dec 09 '18 16:12 kon-foo