embeddable-hn
Embed Hacker News comment tree automatically on your website.
How it works
There is always better discussion on HN than in your Disqus comment box. Instead of a link to HN, you can embed it on your page.
Benefits:
-
Value-add your readers from other sources.
-
Boost site ranking and SEO. (GoogleBot executes JavaScript).
-
Keep discussion on your page.
-
Alternatively, checkout txtpen for highlights and inline comments.
This tool queries from hn.algolia.com/api
so the response time is around ~10ms. It won’t slow your page down.
Basic Usage
-
Embed the javascript file.
a. Put these lines at the top of page before
</head>
<link rel="preload" href="https://txtpen.codes/txtpen-hn-embed.min.js" as="script"> <link href="https://txtpen.codes/txtpen-hn-embed.min.css" rel="stylesheet">
b. Put this after
</body>
tag<script src="https://txtpen.codes/txtpen-hn-embed.min.js"></script>
-
Add HTML tag to embed comment tree.
<txtpen-hn-comment> </txtpen-hn-comment>
-
That’s it. Enjoy :+1:
-
Optional: if you want to specify the Story ID, add a meta tag similar to the one below. Otherwise it will query the url and link the corresponding HN comments automatically.
<meta property="hacker-news" content="{PUT_YOUR_STORY_ID_HERE}">
Development
git clone https://github.com/txtpen/hn.git
cd hn
npm install
npm run dev
# Production build:
# npm run build