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

Slack %SLUG% #78

Open
ghost opened this issue Jul 12, 2018 · 3 comments
Open

Slack %SLUG% #78

ghost opened this issue Jul 12, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 12, 2018

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?

@gka
Copy link
Member

gka commented Nov 25, 2018

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
Copy link
Member

gka commented Nov 28, 2018

closing this for now

@gka gka closed this as completed Nov 28, 2018
@kon-foo
Copy link

kon-foo commented Dec 9, 2018

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

@gka gka reopened this Dec 9, 2018
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