1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Updated website

This commit is contained in:
Laurent Cozic
2020-10-21 00:27:11 +01:00
parent 3d8577a689
commit 45a0981d05
37 changed files with 535 additions and 67 deletions

View File

@@ -495,14 +495,14 @@ joplin.plugins.register({
});
</code></pre>
<p>Later you will also need a way to generate the slug for each header. A slug is an identifier which is used to link to a particular header. Essentially a header text like &quot;My Header&quot; is converted to &quot;my-header&quot;. And if there's already a slug with that name, a number is appended to it. Without going into too much details, you will need the &quot;slug&quot; package to generate this for you, so install it using <code>npm i -s slug</code> from the root of your plugin directory.</p>
<p>Later you will also need a way to generate the slug for each header. A slug is an identifier which is used to link to a particular header. Essentially a header text like &quot;My Header&quot; is converted to &quot;my-header&quot;. And if there's already a slug with that name, a number is appended to it. Without going into too much details, you will need the &quot;slug&quot; package to generate this for you, so install it using <code>npm i -s 'git+https://github.com/laurent22/uslug.git#emoji-support'</code> from the root of your plugin directory (Note: you can also install the &quot;uslug&quot; package on its own, but it won't have emoji support).</p>
<p>Then this is the function you will need for Joplin, so copy it somewhere in your file:</p>
<pre><code class="language-typescript">const nodeSlug = require('slug');
<pre><code class="language-typescript">const uslug = require('uslug');
let slugs = {};
function headerSlug(headerText) {
const s = nodeSlug(headerText);
const s = uslug(headerText);
let num = slugs[s] ? slugs[s] : 1;
const output = [s];
if (num &gt; 1) output.push(num);
@@ -653,9 +653,7 @@ document.addEventListener('click', event =&gt; {
if (message.name === 'scrollToHash') {
// As the name says, the scrollToHash command makes the note scroll
// to the provided hash.
joplin.commands.execute('scrollToHash', {
hash: message.hash,
})
joplin.commands.execute('scrollToHash', message.hash)
}
});