Synchronized build
This commit is contained in:
parent
8763c86f1e
commit
792bf222e6
|
@ -151,7 +151,7 @@ speak multiple languages and allow you to easily create localized websites.</li>
|
|||
<div class="slideshow-wrapper">
|
||||
<div class="slideshow">
|
||||
<div class="slideshow-inner">
|
||||
<div class="carousel slide" data-ride="carousel" data-interval="8500" id="carousel-1135bd614e8c4959b651c82645b4c5e7">
|
||||
<div class="carousel slide" data-ride="carousel" data-interval="8500" id="carousel-e816b82cce294be68564d6684183ee7b">
|
||||
|
||||
<div class="carousel-inner" role="listbox">
|
||||
|
||||
|
@ -210,11 +210,11 @@ be completely customized.</p>
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<a class="left carousel-control" href="#carousel-1135bd614e8c4959b651c82645b4c5e7" role="button" data-slide="prev">
|
||||
<a class="left carousel-control" href="#carousel-e816b82cce294be68564d6684183ee7b" role="button" data-slide="prev">
|
||||
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
|
||||
<span class="sr-only">Previous</span>
|
||||
</a>
|
||||
<a class="right carousel-control" href="#carousel-1135bd614e8c4959b651c82645b4c5e7" role="button" data-slide="next">
|
||||
<a class="right carousel-control" href="#carousel-e816b82cce294be68564d6684183ee7b" role="button" data-slide="next">
|
||||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
||||
<span class="sr-only">Next</span>
|
||||
</a>
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
<h2>Configuration</h2>
|
||||
<p>Here is a basic configuration:</p>
|
||||
<pre lang="ini"><span class="k">[feed]</span>
|
||||
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">My Site's Blog</span>
|
||||
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">My Site's Blog</span>
|
||||
<span class="na">source_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/blog</span>
|
||||
<span class="na">url_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/feed.xml</span>
|
||||
</pre>
|
||||
|
@ -153,14 +153,14 @@
|
|||
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">My Blog</span>
|
||||
<span class="na">source_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/</span>
|
||||
<span class="na">url_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/feed.xml</span>
|
||||
<span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">site.query('/').filter(F.type == 'post')</span>
|
||||
<span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">site.query('/').filter(F.type == 'post')</span>
|
||||
<span class="na">item_model</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">blog-post</span>
|
||||
|
||||
<span class="k">[coffee]</span>
|
||||
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">My Blog: Articles About Coffee</span>
|
||||
<span class="na">source_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/</span>
|
||||
<span class="na">url_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/category/coffee/feed.xml</span>
|
||||
<span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">site.query('/blog').filter(F.categories.contains('coffee'))</span>
|
||||
<span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">site.query('/blog').filter(F.categories.contains('coffee'))</span>
|
||||
<span class="na">item_model</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">blog-post</span>
|
||||
</pre>
|
||||
<p>The section names, like <code>blog</code> and <code>coffee</code>, are just used as internal identifiers.</p>
|
||||
|
|
|
@ -154,23 +154,23 @@ files = A.bib B.bib
|
|||
<p>For the default template, you can also add the following javascript to show some entries if you have a long list (relies on jquery):</p>
|
||||
<pre><code>$(document).ready(function()
|
||||
{
|
||||
$(".BIBTeX").hide();
|
||||
$(".BIBTeXtoggle").click( function () {
|
||||
$(this).parent().children(".BIBTeX").toggle(300);
|
||||
$(".BIBTeX").hide();
|
||||
$(".BIBTeXtoggle").click( function () {
|
||||
$(this).parent().children(".BIBTeX").toggle(300);
|
||||
return false;
|
||||
});
|
||||
$(".BIBYear").hide();
|
||||
$(".BIBYear:first").show();
|
||||
$(".BIBYearheader").click( function () {
|
||||
$(this).parent().children(".BIBYear").toggle(300);
|
||||
$(".BIBYear").hide();
|
||||
$(".BIBYear:first").show();
|
||||
$(".BIBYearheader").click( function () {
|
||||
$(this).parent().children(".BIBYear").toggle(300);
|
||||
return false;
|
||||
});
|
||||
$(".bibshowall").click( function () {
|
||||
$(".BIBYear").show();
|
||||
$(".bibshowall").click( function () {
|
||||
$(".BIBYear").show();
|
||||
});
|
||||
$(".bibhideall").click( function () {
|
||||
$(".BIBYear").hide();
|
||||
$(".BIBYear:first").show();
|
||||
$(".bibhideall").click( function () {
|
||||
$(".BIBYear").hide();
|
||||
$(".BIBYear:first").show();
|
||||
});
|
||||
});
|
||||
</code></pre>
|
||||
|
|
|
@ -149,7 +149,7 @@ link = /for-example/link-to-your/biblioprahy
|
|||
<ol>
|
||||
<li>Use method citation_short_output in the template of your literature page. It creates an unordered list of entries.</li>
|
||||
</ol>
|
||||
<pre><code> <ul id="literatur">
|
||||
<pre><code> <ul id="literatur">
|
||||
{% for entry in citation_entries() %}
|
||||
{{ citation_short_output(entry)|decode|safe }}
|
||||
{% endfor %}
|
||||
|
@ -166,16 +166,16 @@ link = /for-example/link-to-your/biblioprahy
|
|||
<p>produces</p>
|
||||
<pre><code><h2>{title}</h2><h3>{authors} ({pubYear})</h3>
|
||||
<p>{note}</p>
|
||||
<dl class="literature">
|
||||
<dt class="edition"></dt>
|
||||
<dl class="literature">
|
||||
<dt class="edition"></dt>
|
||||
<dd>{edition}</dd>
|
||||
<dt class="editors"></dt>
|
||||
<dt class="editors"></dt>
|
||||
<dd>{editors}</dd>
|
||||
<dt class="pages"></dt>
|
||||
<dt class="pages"></dt>
|
||||
<dd>{pages}</dd>
|
||||
<dt class="issbn"></dt>
|
||||
<dt class="issbn"></dt>
|
||||
<dd>{issbn}</dd>
|
||||
<dt class="publisher"></dt>
|
||||
<dt class="publisher"></dt>
|
||||
<dd>{publisher}</dd>
|
||||
</dl>
|
||||
</code></pre>
|
||||
|
@ -206,8 +206,8 @@ citation_note(entry)
|
|||
</code></pre>
|
||||
<h3>In-text Cites</h3>
|
||||
<p>To cite a certain entry in your texts you can use the <strong>jinja_env globals</strong>:</p>
|
||||
<pre><code>citation_full_cite(id, link="")
|
||||
citation_full_citeNP(id, link="")
|
||||
<pre><code>citation_full_cite(id, link="")
|
||||
citation_full_citeNP(id, link="")
|
||||
</code></pre>
|
||||
<p>Both methods create a complete hyperlink inside your text for the entry with <em>id</em>. You may give it any url to the <em>link</em> parameter to e.g. link it to your bibliography page. The NP in the second stands for <em>No Parantheses</em>. So you'll receive e.g.</p>
|
||||
<pre><code>AuthorI & AuthorII (2019)
|
||||
|
|
|
@ -140,7 +140,7 @@
|
|||
<p>Lektor plugin to add Creative Commons license to your pages</p>
|
||||
<h2>Usage</h2>
|
||||
<p>On your templates use:</p>
|
||||
<pre><code><div class="license">{{ render_cc_license(type, size, template, caller) }}</div>
|
||||
<pre><code><div class="license">{{ render_cc_license(type, size, template, caller) }}</div>
|
||||
</code></pre>
|
||||
<ul>
|
||||
<li><code>type</code> is a <code>string</code> with the license type (e.g.: <code>'by'</code>, <code>'by-sa'</code>, <code>'by-nc-sa'</code>).</li>
|
||||
|
@ -151,12 +151,12 @@
|
|||
</ul>
|
||||
<h2>Examples</h2>
|
||||
<p>Simply rendering the license of your choice:</p>
|
||||
<pre><code><div class="license">{{ render_cc_license('by-sa') }}</div>
|
||||
<pre><code><div class="license">{{ render_cc_license('by-sa') }}</div>
|
||||
</code></pre>
|
||||
<p>Using Jinja2 <a href="http://jinja.pocoo.org/docs/2.10/templates/#call" rel="nofollow">call</a> block to inject your own template:</p>
|
||||
<pre><code>{% call(license, license_url, icon_path) render_cc_license('by-sa', size='normal') %}
|
||||
<a class="nav-item" rel="license" target="_blank" href="{{ license_url }}">
|
||||
<img alt="{{ license }}" style="border-width:0" src="{{ icon_path }}" />
|
||||
<a class="nav-item" rel="license" target="_blank" href="{{ license_url }}">
|
||||
<img alt="{{ license }}" style="border-width:0" src="{{ icon_path }}" />
|
||||
</a>
|
||||
{% endcall %}
|
||||
</code></pre>
|
||||
|
|
|
@ -152,7 +152,7 @@ your disqus community:</p>
|
|||
<p>Now you can add a discussion box to any of your templates by just using
|
||||
the <code>render_disqus_comments</code> function. Just calling it is enough to
|
||||
get the comment box:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"comments"</span><span class="p">></span>{{ render_disqus_comments() }}<span class="p"></</span><span class="nt">div</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"comments"</span><span class="p">></span>{{ render_disqus_comments() }}<span class="p"></</span><span class="nt">div</span><span class="p">></span>
|
||||
</pre>
|
||||
<p>Optionally the function accepts a few arguemnts:</p>
|
||||
<ul>
|
||||
|
|
|
@ -181,11 +181,11 @@ then in the page template (e.g. in <code>templates/index.html</code>) one could
|
|||
reference the <code>items</code> field (e.g. <code>{% for page in this.items %}</code>)
|
||||
to determine which pages to display on the page.</p>
|
||||
<h2>Author</h2>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org">dairiki@dairiki.org</a></p>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org" rel="nofollow">dairiki@dairiki.org</a></p>
|
||||
<h2>Changelog</h2>
|
||||
<h3>0.1 — 2021-02-05</h3>
|
||||
<p>No code changes.</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<h4>Fixes</h4>
|
||||
<ul>
|
||||
<li>Include the correct LICENSE file.</li>
|
||||
|
|
|
@ -244,7 +244,7 @@ Unfortunately, the last released version of Lektor (as of August 12,
|
|||
to install Lektor from git if you want to be able to sort records by
|
||||
<code>gittimestamp</code>.</p>
|
||||
<h2>Author</h2>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org">dairiki@dairiki.org</a></p>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org" rel="nofollow">dairiki@dairiki.org</a></p>
|
||||
<h2>Changelog</h2>
|
||||
<h3>Release 0.1.0.post1 (2021-08-12)</h3>
|
||||
<p>No code changes.</p>
|
||||
|
@ -252,7 +252,7 @@ to install Lektor from git if you want to be able to sort records by
|
|||
required in order to be able to sort records by <code>gittimestamp</code> fields.</p>
|
||||
<h3>Release 0.1 (2021-02-05)</h3>
|
||||
<p>No code changes.</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Add functional tests.</p>
|
||||
<h3>Release 0.1a2 (2021-02-03)</h3>
|
||||
<h4>Bugs Fixed</h4>
|
||||
|
|
|
@ -157,7 +157,7 @@ folder in your Lektor project’s base directory. And, put the
|
|||
<h3>Using in Templates</h3>
|
||||
<p>Now you can add a Google analytics code-snippet in your templates by
|
||||
just calling the <span class="docutils literal">generate_google_analytics</span> function inside its <span class="docutils literal"><body> </body></span> tags.</p>
|
||||
<pre><code><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><s>"ga-script"</s><span class="p">></span>{{ generate_google_analytics() }}<span class="p"></</span><span class="nt">div</span><span class="p">></span></code></pre>
|
||||
<pre><code><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><s>"ga-script"</s><span class="p">></span>{{ generate_google_analytics() }}<span class="p"></</span><span class="nt">div</span><span class="p">></span></code></pre>
|
||||
<p>That’s it. All the <span class="docutils literal">HTML</span> files that rendered from that template will
|
||||
include Google-Analytics code automatically.</p>
|
||||
</section>
|
||||
|
|
|
@ -131,17 +131,17 @@ can deposit scholarly documents from all academic fields.</p>
|
|||
<p>In <code>./configs/hal.ini</code>, the query field must be specified, following to the
|
||||
<a href="https://api.archives-ouvertes.fr/docs/search" rel="nofollow">HAL docs</a></p>
|
||||
<p>Example:</p>
|
||||
<pre><code>query = ((authIdHal_s:my-id-hal) OR (authFullName_s:"My Name"))
|
||||
<pre><code>query = ((authIdHal_s:my-id-hal) OR (authFullName_s:"My Name"))
|
||||
</code></pre>
|
||||
<h2>Usage</h2>
|
||||
<h3>Example</h3>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">ul</span> <span class="na">class</span><span class="o">=</span><span class="s">"publications"</span> <span class="na">id</span><span class="o">=</span><span class="s">"publications"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">ul</span> <span class="na">class</span><span class="o">=</span><span class="s">"publications"</span> <span class="na">id</span><span class="o">=</span><span class="s">"publications"</span><span class="p">></span>
|
||||
{% for publi in hal_publications %}
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">{{</span> <span class="na">publi</span><span class="err">.</span><span class="na">link</span> <span class="err">}}</span><span class="p">></span>{{ publi.title }}<span class="p"></</span><span class="nt">a</span><span class="p">></span>
|
||||
@
|
||||
{{ publi.where }} -
|
||||
{{ publi.authors|join(', ') }}
|
||||
{{ publi.authors|join(', ') }}
|
||||
({{ publi.date }})
|
||||
<span class="p"></</span><span class="nt">li</span><span class="p">></span>
|
||||
{% endfor %}
|
||||
|
@ -158,7 +158,7 @@ HAL API.</li>
|
|||
<li><code>hal_id</code>: The HAL ID of the publication</li>
|
||||
<li><code>authors</code>: A list of strings (author names)</li>
|
||||
<li><code>date</code>: A string (<code>producedDate_s</code>)</li>
|
||||
<li><code>type</code>: The publication type, eg "ART", "COMM", "POSTER", etc/</li>
|
||||
<li><code>type</code>: The publication type, eg "ART", "COMM", "POSTER", etc/</li>
|
||||
</ul>
|
||||
<p>and properties:</p>
|
||||
<ul>
|
||||
|
@ -171,7 +171,7 @@ if missing)</li>
|
|||
<h2>Known caveat</h2>
|
||||
<p>Lektor will not 'know' that the page must be rebuilt when new entries are
|
||||
returned by the HAL API request.
|
||||
As a workaround, the plugin allows to mark any page as "dirty", so it is rebuilt
|
||||
As a workaround, the plugin allows to mark any page as "dirty", so it is rebuilt
|
||||
everytime. Add this to the template that uses the publications list:</p>
|
||||
<pre lang="jinja2">{{ volatile() }}
|
||||
</pre>
|
||||
|
|
|
@ -146,14 +146,14 @@ For example, you may have an image called <code>waffle.jpg</code>, and to link t
|
|||
All images will be converted to webp using <a href="https://pypi.org/project/Pillow/" rel="nofollow">Pillow</a>.</p>
|
||||
<p>You can use the images like that:</p>
|
||||
<pre lang="html"><span class="cm"><!-- Simple example --></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"waffle.jpg"</span><span class="p">><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"waffle-small.jpg"</span> <span class="p">/></</span><span class="nt">a</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"waffle.jpg"</span><span class="p">><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"waffle-small.jpg"</span> <span class="p">/></</span><span class="nt">a</span><span class="p">></span>
|
||||
|
||||
<span class="cm"><!-- example with srcset --></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"waffle-small.webp"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"waffle-small.webp"</span>
|
||||
<span class="na">srcset</span><span class="o">=</span><span class="s">"waffle-small.webp 640w, // Viewport bis zu 640</span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"waffle-small.webp"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"waffle-small.webp"</span>
|
||||
<span class="na">srcset</span><span class="o">=</span><span class="s">"waffle-small.webp 640w, // Viewport bis zu 640</span>
|
||||
<span class="s"> waffle-medium.webp 1280w, // Viewport größer als 1280</span>
|
||||
<span class="s"> waffle-woowee.webp 1920w"</span> <span class="err">//</span> <span class="na">Viewport</span> <span class="na">größer</span> <span class="na">als</span> <span class="na">1920</span>
|
||||
<span class="s"> waffle-woowee.webp 1920w"</span> <span class="err">//</span> <span class="na">Viewport</span> <span class="na">größer</span> <span class="na">als</span> <span class="na">1920</span>
|
||||
<span class="p">/></span>
|
||||
<span class="p"></</span><span class="nt">a</span><span class="p">></span>
|
||||
</pre>
|
||||
|
|
|
@ -157,7 +157,7 @@ the build process down too excruciatingly much.</p>
|
|||
<li><a href="https://pypi.org/project/lektor-index-pages/" rel="nofollow">PyPI</a></li>
|
||||
</ul>
|
||||
<h2>Author</h2>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org">dairiki@dairiki.org</a></p>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org" rel="nofollow">dairiki@dairiki.org</a></p>
|
||||
<h2>Changelog</h2>
|
||||
<h3>Release 1.1.0 (2023-06-16)</h3>
|
||||
<ul>
|
||||
|
@ -193,7 +193,7 @@ the build process down too excruciatingly much.</p>
|
|||
</ul>
|
||||
<h3>Release 0.1 (2021-02-05)</h3>
|
||||
<p>No code changes.</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<h3>Release 0.1a3 (2020-05-08)</h3>
|
||||
<h4>API changes</h4>
|
||||
<ul>
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">meaning_of_life</span> <span class="o">==</span> <span class="nv">meaning_of_universe</span> <span class="o">==</span> <span class="m">42</span> <span class="cp">%}</span>
|
||||
<span class="x"> </span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">meaning_of_it_all</span> <span class="o">=</span> <span class="nv">meaning_of_life</span> <span class="cp">%}</span>
|
||||
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span>
|
||||
<span class="x"> </span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">meaning_of_it_all</span> <span class="o">=</span> <span class="s1">'Undefined'</span> <span class="cp">%}</span>
|
||||
<span class="x"> </span><span class="cp">{%</span> <span class="k">set</span> <span class="nv">meaning_of_it_all</span> <span class="o">=</span> <span class="s1">'Undefined'</span> <span class="cp">%}</span>
|
||||
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
|
||||
<span class="cp">{{</span> <span class="nv">meaning_of_it_all</span> <span class="cp">}}</span>
|
||||
</pre>
|
||||
|
|
|
@ -133,8 +133,8 @@ in the sidebar of your Lektor-based site. This can be done by adding
|
|||
something like to your site base template:</p>
|
||||
<pre lang="html+jinja"><span class="p"><</span><span class="nt">h3</span><span class="p">></span>Recent Posts<span class="p"></</span><span class="nt">h3</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ul</span><span class="p">></span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">post</span> <span class="k">in</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">'/blog'</span><span class="o">)</span><span class="nv">.order_by</span><span class="o">(</span><span class="s1">'-pub_date'</span><span class="o">)</span><span class="nv">.limit</span><span class="o">(</span><span class="m">3</span><span class="o">)</span> <span class="cp">%}</span>
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">post</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">"</span><span class="p">></span><span class="cp">{{</span> <span class="nv">post.title</span> <span class="cp">}}</span><span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">post</span> <span class="k">in</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">'/blog'</span><span class="o">)</span><span class="nv">.order_by</span><span class="o">(</span><span class="s1">'-pub_date'</span><span class="o">)</span><span class="nv">.limit</span><span class="o">(</span><span class="m">3</span><span class="o">)</span> <span class="cp">%}</span>
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">post</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">"</span><span class="p">></span><span class="cp">{{</span> <span class="nv">post.title</span> <span class="cp">}}</span><span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
|
||||
<span class="p"></</span><span class="nt">ul</span><span class="p">></span>
|
||||
</pre>
|
||||
|
@ -177,8 +177,8 @@ most-recent posts.)</p>
|
|||
<p>Thus, the example above, if replaced by:</p>
|
||||
<pre lang="html+jinja"><span class="p"><</span><span class="nt">h3</span><span class="p">></span>Recent Posts<span class="p"></</span><span class="nt">h3</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ul</span><span class="p">></span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">post</span> <span class="k">in</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">'/blog'</span><span class="o">)</span><span class="nv">.order_by</span><span class="o">(</span><span class="s1">'-pub_date'</span><span class="o">)</span><span class="nv">.limit</span><span class="o">(</span><span class="m">3</span><span class="o">)|</span><span class="nf">limit_dependencies</span> <span class="cp">%}</span>
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">post</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">"</span><span class="p">></span><span class="cp">{{</span> <span class="nv">post.title</span> <span class="cp">}}</span><span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">post</span> <span class="k">in</span> <span class="nv">site.query</span><span class="o">(</span><span class="s1">'/blog'</span><span class="o">)</span><span class="nv">.order_by</span><span class="o">(</span><span class="s1">'-pub_date'</span><span class="o">)</span><span class="nv">.limit</span><span class="o">(</span><span class="m">3</span><span class="o">)|</span><span class="nf">limit_dependencies</span> <span class="cp">%}</span>
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">post</span><span class="o">|</span><span class="nf">url</span> <span class="cp">}}</span><span class="s">"</span><span class="p">></span><span class="cp">{{</span> <span class="nv">post.title</span> <span class="cp">}}</span><span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
|
||||
<span class="p"></</span><span class="nt">ul</span><span class="p">></span>
|
||||
</pre>
|
||||
|
@ -191,7 +191,7 @@ of the three most recent posts.</p>
|
|||
</code></pre>
|
||||
<p>See <a href="https://www.getlektor.com/docs/plugins/" rel="nofollow">the Lektor plugin documentation</a> for more information.</p>
|
||||
<h2>Author</h2>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org">dairiki@dairiki.org</a></p>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org" rel="nofollow">dairiki@dairiki.org</a></p>
|
||||
<h2>Changelog</h2>
|
||||
<h3>Release 1.0.0 (2023-01-31)</h3>
|
||||
<p>No code changes from 1.0.0b1.</p>
|
||||
|
@ -200,7 +200,7 @@ of the three most recent posts.</p>
|
|||
<p>Drop support for python<3.7 and lektor<3.3.</p>
|
||||
<h3>Release 0.1 (2021-02-05)</h3>
|
||||
<p>No code changes.</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Test under python 3.9. Stop testing under 3.5.</p>
|
||||
<h3>Release 0.1a1 (2020-05-19)</h3>
|
||||
<p>Initial release.</p>
|
||||
|
|
|
@ -158,19 +158,19 @@ inspired by the extension in Python Markdown but simplified.</p>
|
|||
<tbody>
|
||||
<tr>
|
||||
<td align="left">!</td>
|
||||
<td align="left"><code><div class="admonition admonition-note"></code></td>
|
||||
<td align="left"><code><div class="admonition admonition-note"></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">!!</td>
|
||||
<td align="left"><code><div class="admonition admonition-info"></code></td>
|
||||
<td align="left"><code><div class="admonition admonition-info"></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">!!!</td>
|
||||
<td align="left"><code><div class="admonition admonition-tip"></code></td>
|
||||
<td align="left"><code><div class="admonition admonition-tip"></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">!!!!</td>
|
||||
<td align="left"><code><div class="admonition admonition-warning"></code></td>
|
||||
<td align="left"><code><div class="admonition admonition-warning"></code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -159,9 +159,9 @@ markdown data. It's a list where each item has the following attributes:</p>
|
|||
</ul>
|
||||
<p>Example rendering:</p>
|
||||
<pre lang="jinja"><span class="x"><h4>Table Of Contents</h4></span>
|
||||
<span class="x"><ul class="toc"></span>
|
||||
<span class="x"><ul class="toc"></span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">item</span> <span class="k">in</span> <span class="nv">this.body.toc</span> <span class="k">recursive</span> <span class="cp">%}</span>
|
||||
<span class="x"> <li><a href="#</span><span class="cp">{{</span> <span class="nv">item.anchor</span> <span class="cp">}}</span><span class="x">"></span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="x"></a></span><span class="cp">{%</span>
|
||||
<span class="x"> <li><a href="#</span><span class="cp">{{</span> <span class="nv">item.anchor</span> <span class="cp">}}</span><span class="x">"></span><span class="cp">{{</span> <span class="nv">item.title</span> <span class="cp">}}</span><span class="x"></a></span><span class="cp">{%</span>
|
||||
<span class="k">if</span> <span class="nv">item.children</span> <span class="cp">%}</span><span class="x"><ul></span><span class="cp">{{</span> <span class="nb">loop</span><span class="o">(</span><span class="nv">item.children</span><span class="o">)</span> <span class="cp">}}</span><span class="x"></ul></span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></li></span>
|
||||
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
|
||||
<span class="x"></ul></span>
|
||||
|
|
|
@ -152,22 +152,22 @@ for Pygments. Just create a file named <code>markdown-highlighter.ini</code> in
|
|||
</pre>
|
||||
<p>You can use this to select any of the built-in Pygments styles. Support for
|
||||
custom styles will come in the future.</p>
|
||||
<p>The config file is considered the "source" for the Pygments stylesheet, so you must create the configuration file (it can be empty) or Lektor's build will prune <code>pygments.css</code>.</p>
|
||||
<p>The config file is considered the "source" for the Pygments stylesheet, so you must create the configuration file (it can be empty) or Lektor's build will prune <code>pygments.css</code>.</p>
|
||||
<h2>In Markdown</h2>
|
||||
<p>To use the syntax highlighter you need to use fenced blocks and pass the name
|
||||
of the pygments lexer after the opening fence:</p>
|
||||
<pre><code>```python
|
||||
print("Hello World!")
|
||||
print("Hello World!")
|
||||
```
|
||||
</code></pre>
|
||||
<h2>In Templates</h2>
|
||||
<p>In templates the plugin provides the <code>get_pygments_stylesheet</code> function which
|
||||
can be used to generate and retrieve a link to the pygments stylesheet:</p>
|
||||
<pre lang="jinja"><span class="x"><link rel="stylesheet" href="</span><span class="cp">{{</span> <span class="nv">get_pygments_stylesheet</span><span class="o">()|</span><span class="nf">url</span> <span class="cp">}}</span><span class="x">"></span>
|
||||
<pre lang="jinja"><span class="x"><link rel="stylesheet" href="</span><span class="cp">{{</span> <span class="nv">get_pygments_stylesheet</span><span class="o">()|</span><span class="nf">url</span> <span class="cp">}}</span><span class="x">"></span>
|
||||
</pre>
|
||||
<p>In addition the <code>|pygmentize</code> filter can be used to highlight code from
|
||||
templates. It takes one argument which is the lexer name:</p>
|
||||
<pre lang="jinja"><span class="cp">{{</span> <span class="s1">'print "Hello World!"'</span><span class="o">|</span><span class="nf">pygmentize</span><span class="o">(</span><span class="s1">'python'</span><span class="o">)</span> <span class="cp">}}</span>
|
||||
<pre lang="jinja"><span class="cp">{{</span> <span class="s1">'print "Hello World!"'</span><span class="o">|</span><span class="nf">pygmentize</span><span class="o">(</span><span class="s1">'python'</span><span class="o">)</span> <span class="cp">}}</span>
|
||||
</pre>
|
||||
|
||||
|
||||
|
|
|
@ -128,14 +128,14 @@ HTML ruby tags to Markdown.</p>
|
|||
^^
|
||||
</pre>
|
||||
<p>This will generate the following HTML:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
</pre>
|
||||
<p>The rendering result:</p>
|
||||
<p>
|
||||
<span class="ruby-line">
|
||||
<ruby>歩<rp>(</rp><rt>ある</rt><rp>)</rp></ruby>く
|
||||
歩(ある)く
|
||||
</span>
|
||||
</p>
|
||||
<p>You can combine adjacent ruby text like this:</p>
|
||||
|
@ -144,15 +144,15 @@ HTML ruby tags to Markdown.</p>
|
|||
^^
|
||||
</pre>
|
||||
<p>And this will be rendered like this:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>自<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>じ<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>分<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ぶん<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
</pre>
|
||||
<p>Rendered output:</p>
|
||||
<span class="ruby-line">
|
||||
<ruby>自<rp>(</rp><rt>じ</rt><rp>)</rp></ruby>
|
||||
<ruby>分<rp>(</rp><rt>ぶん</rt><rp>)</rp></ruby>
|
||||
自(じ)
|
||||
分(ぶん)
|
||||
</span>
|
||||
<h3>Newline</h3>
|
||||
<p>This plugin will automatically add <code><br /></code> between each line in a ruby-block:</p>
|
||||
|
@ -162,11 +162,11 @@ HTML ruby tags to Markdown.</p>
|
|||
^^
|
||||
</pre>
|
||||
<p>This will output:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">br</span> <span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
</pre>
|
||||
|
@ -178,12 +178,12 @@ HTML ruby tags to Markdown.</p>
|
|||
^^
|
||||
</pre>
|
||||
<p>Output:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">br</span> <span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">br</span> <span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
</pre>
|
||||
|
@ -196,12 +196,12 @@ with specified color.</p>
|
|||
^^
|
||||
</pre>
|
||||
<p>This will generate the following HTML pieces:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span> <span class="na">style</span><span class="o">=</span><span class="s">"color: #44cc00"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span> <span class="na">style</span><span class="o">=</span><span class="s">"color: #44cc00"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
</pre>
|
||||
<h3>Raw lines</h3>
|
||||
<p>Prepend <code>% </code> to create a raw line. Raw lines are not converted to ruby tags,
|
||||
<p>Prepend <code>% </code> to create a raw line. Raw lines are not converted to ruby tags,
|
||||
not affected by the color settings, and have a different class.</p>
|
||||
<p>Example:</p>
|
||||
<pre lang="markdown">^^#44cc00
|
||||
|
@ -210,11 +210,11 @@ not affected by the color settings, and have a different class.</p>
|
|||
^^
|
||||
</pre>
|
||||
<p>Output:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span> <span class="na">style</span><span class="o">=</span><span class="s">"color: #44cc00"</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"ruby-line"</span> <span class="na">style</span><span class="o">=</span><span class="s">"color: #44cc00"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ruby</span><span class="p">></span>歩<span class="p"><</span><span class="nt">rp</span><span class="p">></span>(<span class="p"></</span><span class="nt">rp</span><span class="p">><</span><span class="nt">rt</span><span class="p">></span>ある<span class="p"></</span><span class="nt">rt</span><span class="p">><</span><span class="nt">rp</span><span class="p">></span>)<span class="p"></</span><span class="nt">rp</span><span class="p">></</span><span class="nt">ruby</span><span class="p">></span>く
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">br</span> <span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"non-ruby-line"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"non-ruby-line"</span><span class="p">></span>
|
||||
(aru)[ku]
|
||||
<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
</pre>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<span class="na">target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">netlify://my-domain.com</span>
|
||||
</pre>
|
||||
<h2>Access Token</h2>
|
||||
<p>Get a personal access token from Netlify's "applications" page:</p>
|
||||
<p>Get a personal access token from Netlify's "applications" page:</p>
|
||||
<ul>
|
||||
<li><a href="https://app.netlify.com/applications" rel="nofollow">Applications</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -179,13 +179,13 @@
|
|||
<h3><code>parcel/package.json</code></h3>
|
||||
<p>This is a standard <code>package.json</code> file. It should contain two entries in the <code>scripts</code> section. The <code>build</code> script is used during <code>lektor build -f npm</code>, and the <code>watch</code> script is used during <code>lektor server -f npm</code>.</p>
|
||||
<pre lang="json"><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"my-parcel-project"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.0.0"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"scripts"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nt">"watch"</span><span class="p">:</span><span class="w"> </span><span class="s2">"NODE_ENV=development parcel --out-dir=../assets/static/gen --out-file=main.js --public-url=./assets/ main.js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"build"</span><span class="p">:</span><span class="w"> </span><span class="s2">"NODE_ENV=production parcel build --out-dir=../assets/static/gen --out-file=main.js --public-url=./assets/ main.js"</span>
|
||||
<span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"my-parcel-project"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.0.0"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"scripts"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nt">"watch"</span><span class="p">:</span><span class="w"> </span><span class="s2">"NODE_ENV=development parcel --out-dir=../assets/static/gen --out-file=main.js --public-url=./assets/ main.js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"build"</span><span class="p">:</span><span class="w"> </span><span class="s2">"NODE_ENV=production parcel build --out-dir=../assets/static/gen --out-file=main.js --public-url=./assets/ main.js"</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nt">"private"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span>
|
||||
<span class="w"> </span><span class="nt">"private"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span>
|
||||
<span class="p">}</span>
|
||||
</pre>
|
||||
<p>Now we can use <code>yarn add</code> to add Parcel, <a href="https://babeljs.io/" rel="nofollow">Babel</a> and <a href="https://sass-lang.com/" rel="nofollow">Sass</a>:</p>
|
||||
|
@ -195,7 +195,7 @@ $ yarn add parcel-bundler babel-preset-env node-sass
|
|||
<h3><code>parcel/babelr.rc</code></h3>
|
||||
<p>Next up is a simple Babel config file, using the recommended <code>env</code> preset.</p>
|
||||
<pre lang="json"><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nt">"presets"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"env"</span><span class="p">]</span>
|
||||
<span class="w"> </span><span class="nt">"presets"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"env"</span><span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</pre>
|
||||
<h3><code>parcel/main.scss</code></h3>
|
||||
|
@ -206,7 +206,7 @@ $ yarn add parcel-bundler babel-preset-env node-sass
|
|||
</pre>
|
||||
<h3><code>parcel/main.js</code></h3>
|
||||
<p>A simple Javascript file that imports the SCSS file so that Parcel will know to include it as well.</p>
|
||||
<pre lang="javascript"><span class="k">import</span><span class="w"> </span><span class="s1">'./main.scss'</span><span class="p">;</span>
|
||||
<pre lang="javascript"><span class="k">import</span><span class="w"> </span><span class="s1">'./main.scss'</span><span class="p">;</span>
|
||||
</pre>
|
||||
<h2>Running the Server</h2>
|
||||
<p>Now you're ready to go. When you run <code>lektor server</code> nothing wil happen,
|
||||
|
@ -220,8 +220,8 @@ Lektor website that use this plugin.</p>
|
|||
<p>To manually trigger a build that also invokes webpack you can use <code>lektor build -f npm</code>.</p>
|
||||
<h2>Including The Files</h2>
|
||||
<p>Now you need to include the files in your template. This will do it:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ '/static/gen/main.css'| asseturl }}"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">text/javascript</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ '/static/gen/main.js'| asseturl }}"</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ '/static/gen/main.css'| asseturl }}"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">text/javascript</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ '/static/gen/main.js'| asseturl }}"</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span>
|
||||
</pre>
|
||||
<h2>Complete Working Example</h2>
|
||||
<p>The <code>examples</code> folder of this repository contains working projects.</p>
|
||||
|
|
|
@ -188,17 +188,17 @@ determine whether the <code>body</code> field is interpreted as being <code>mark
|
|||
<span class="k">[fields.body]</span>
|
||||
<span class="na">label</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Body</span>
|
||||
<span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">polymorphic</span>
|
||||
<span class="na">polymorphic_type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">'html' if this.body.lstrip().startswith('<') else 'markdown'</span>
|
||||
<span class="na">polymorphic_type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">'html' if this.body.lstrip().startswith('<') else 'markdown'</span>
|
||||
</pre>
|
||||
<p>In this case, the <code>body</code> field will be interpreted as raw HTML if the
|
||||
content of that field starts with a “<code><</code>”, otherwise it will be
|
||||
interpreted as <em>Markdown</em> text.</p>
|
||||
<h2>Author</h2>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org">dairiki@dairiki.org</a></p>
|
||||
<p>Jeff Dairiki <a href="mailto:dairiki@dairiki.org" rel="nofollow">dairiki@dairiki.org</a></p>
|
||||
<h2>Changelog</h2>
|
||||
<h3>0.1 — 2021-02-05</h3>
|
||||
<p>No code changes.</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Update development status classifier to "stable".</p>
|
||||
<p>Test under python 3.9. Stop testing under 3.5.</p>
|
||||
<h3>0.1b1 — 2020-05-04</h3>
|
||||
<p>Initial release.</p>
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
<span class="na">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span>
|
||||
<span class="na">target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu://<YOUR-BUCKET>/<NAME-OF-FOLDER></span>
|
||||
</pre>
|
||||
<p>for example, if you want to deploy your site to a bucket name "abcde", folder "fjhi", you will need to add a server section as below:</p>
|
||||
<p>for example, if you want to deploy your site to a bucket name "abcde", folder "fjhi", you will need to add a server section as below:</p>
|
||||
<pre lang="ini"><span class="k">[servers.qiniu]</span>
|
||||
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">qiniu</span>
|
||||
<span class="na">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span>
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
<h2>How to use</h2>
|
||||
<p>Insert the following line in the template (e.g. layout.html) which you would like to show navigation.</p>
|
||||
<pre><code>{% for i in this._path | root_relative_path_list %}
|
||||
>><a href="{{i[0]}}">{{i[1]}}</a>
|
||||
>><a href="{{i[0]}}">{{i[1]}}</a>
|
||||
{% endfor %}
|
||||
</code></pre>
|
||||
<p>Then, navigation is shown as below in case the page 'blog/first-post/'</p>
|
||||
|
@ -154,7 +154,7 @@
|
|||
<p>If you do not want to show current page in the navigation, modify template as below.</p>
|
||||
<pre><code>{% for i in this._path | root_relative_path_list %}
|
||||
{% if not loop.last %}
|
||||
>><a href="{{i[0]}}">{{i[1]}}</a>
|
||||
>><a href="{{i[0]}}">{{i[1]}}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</code></pre>
|
||||
|
|
|
@ -140,17 +140,17 @@ something like custom tags) in your fields (not templates), so your content
|
|||
doesn't have to have repetitive snippets over and over.</p>
|
||||
<p>For example, my blog has some specific HTML that I add when I want an image with
|
||||
a border and caption to be displayed. The HTML looks like this:</p>
|
||||
<pre lang="html"> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"alignright"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"image-large.jpg"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"image.jpg"</span> <span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"caption"</span><span class="p">></span>The caption<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
<pre lang="html"> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"alignright"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"image-large.jpg"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"image.jpg"</span> <span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"caption"</span><span class="p">></span>The caption<span class="p"></</span><span class="nt">span</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">a</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
|
||||
</pre>
|
||||
<p>Copy-pasting this every time gets tedious, and I have to search and replace it
|
||||
in all the content files every time I want to make a change. With the
|
||||
shortcodes plugin, this can be written as:</p>
|
||||
<pre><code>[% image align=right link="image-large.jpg" image=image.jpg caption="The caption" %]
|
||||
<pre><code>[% image align=right link="image-large.jpg" image=image.jpg caption="The caption" %]
|
||||
</code></pre>
|
||||
<p>Much easier, cleaner and less repetitive.</p>
|
||||
<h2>Installation</h2>
|
||||
|
@ -165,7 +165,7 @@ full Jinja templates, although (due to some limitations of ini files) they need
|
|||
to be on one line.</p>
|
||||
<p>For instance, for the example above, the config file could be:</p>
|
||||
<pre lang="ini"><span class="k">[global]</span>
|
||||
<span class="na">image</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">'<div class="align{{ align }}">{% if link %}<a href="{{ link }}"{% if not link.startswith("http") %} data-lightbox="gallery"{% endif %}>{% endif %}<img src="{{ image }}">{% if link %}</a>{% endif %}{% if caption %}<span class="caption">{{ caption }}</span>{% endif %}</div>'</span>
|
||||
<span class="na">image</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">'<div class="align{{ align }}">{% if link %}<a href="{{ link }}"{% if not link.startswith("http") %} data-lightbox="gallery"{% endif %}>{% endif %}<img src="{{ image }}">{% if link %}</a>{% endif %}{% if caption %}<span class="caption">{{ caption }}</span>{% endif %}</div>'</span>
|
||||
</pre>
|
||||
<p>This will allow you to use shortcodes with optional arguments, like so:</p>
|
||||
<pre><code># An image with no caption or link:
|
||||
|
@ -176,7 +176,7 @@ to be on one line.</p>
|
|||
[% image align=right link=http://www.example.com image=hello.jpg %]
|
||||
|
||||
# Link and caption:
|
||||
[% image align=right link=http://www.example.com image=hello.jpg caption="Hello!" %]
|
||||
[% image align=right link=http://www.example.com image=hello.jpg caption="Hello!" %]
|
||||
</code></pre>
|
||||
<p>Shortcodes defined within the section named <code>global</code> will be processed
|
||||
automatically inside any of your site’s Markdown content. It is also possible to
|
||||
|
@ -186,7 +186,7 @@ will only be applied when the template passed the content through a Jinja2
|
|||
filter named <code>shortcode</code>. For example, if your HTML template references a field
|
||||
called <code>body</code>, and your config has a section called <code>[special]</code>, you may request
|
||||
expanding shortcodes defined within the <code>special</code> section like so:</p>
|
||||
<pre><code>{{ body|shortcodes(section="special") }}
|
||||
<pre><code>{{ body|shortcodes(section="special") }}
|
||||
</code></pre>
|
||||
<p>This will enable all shortcodes from the specified section, in addition to all
|
||||
globally defined shortcodes. If no section is specified, the filter defaults to
|
||||
|
|
|
@ -131,10 +131,10 @@
|
|||
<p>This is a simple Lektor plugin that creates a template filter to remove HTML tags from a string. The use it was created for was to do processing on HTML outputted from a Markdown content field. The Markdown is rendered into HTML, and this filter can turn that into simple text, which was then passed to the <a href="https://github.com/terminal-labs/lektor-natural-language" rel="nofollow">lektor-natural-language</a> filters to get keywords, unsullied by things like <code><div></code> tags.</p>
|
||||
<p>Example usage:</p>
|
||||
<p><code>{{ this.body|striphtmltags }}</code></p>
|
||||
<pre lang="jinja"><span class="cp">{%</span> <span class="k">set</span> <span class="nv">var</span> <span class="o">=</span> <span class="s1">'<p><strong>Hello</strong>World!</p>'</span> <span class="cp">%}</span>
|
||||
<pre lang="jinja"><span class="cp">{%</span> <span class="k">set</span> <span class="nv">var</span> <span class="o">=</span> <span class="s1">'<p><strong>Hello</strong>World!</p>'</span> <span class="cp">%}</span>
|
||||
<span class="cp">{{</span> <span class="nv">var</span><span class="o">|</span><span class="nf">striphtmltags</span> <span class="cp">}}</span>
|
||||
</pre>
|
||||
<p>The last example will render as "Hello World!"</p>
|
||||
<p>The last example will render as "Hello World!"</p>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ tea
|
|||
</pre>
|
||||
<p>See <a href="https://www.getlektor.com/docs/plugins/" rel="nofollow">the Lektor documentation for more instructions on installing plugins</a>.</p>
|
||||
<h2>Overview</h2>
|
||||
<p>Say you have a "blog-post" model like this:</p>
|
||||
<p>Say you have a "blog-post" model like this:</p>
|
||||
<pre lang="ini"><span class="k">[model]</span>
|
||||
<span class="na">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">Blog Post</span>
|
||||
|
||||
|
@ -167,7 +167,7 @@ tea
|
|||
<span class="p"><</span><span class="nt">ul</span><span class="p">></span>
|
||||
{% for t in this.tags -%}
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ ('/blog@tag/' ~ t)|url }}"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ ('/blog@tag/' ~ t)|url }}"</span><span class="p">></span>
|
||||
All posts tagged {{ t }}
|
||||
<span class="p"></</span><span class="nt">a</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">li</span><span class="p">></span>
|
||||
|
@ -176,13 +176,13 @@ tea
|
|||
{% endif %}
|
||||
</pre>
|
||||
<p>This expression in the template generates a <em>source path</em> for each of the blog post's tags:</p>
|
||||
<pre lang="jinja"><span class="x">'/blog@tag/' ~ t</span>
|
||||
<pre lang="jinja"><span class="x">'/blog@tag/' ~ t</span>
|
||||
</pre>
|
||||
<p>Then if the tag is "my-tag", the expression renders a source path like:</p>
|
||||
<p>Then if the tag is "my-tag", the expression renders a source path like:</p>
|
||||
<pre><code>/blog/tag/my-tag
|
||||
</code></pre>
|
||||
<p>A Lektor source path becomes an actual URL using the <code>url</code> filter. So the template generates URLs to tag pages like:</p>
|
||||
<pre><code><a href="{{ ('/blog@tag/' ~ t)|url }}"></a>
|
||||
<pre><code><a href="{{ ('/blog@tag/' ~ t)|url }}"></a>
|
||||
</code></pre>
|
||||
<p>This uses the source path expression from before, but pipes it through <code>url</code> to generate an actual link from the blog post to a tag page.</p>
|
||||
<h2>Configuration</h2>
|
||||
|
@ -202,7 +202,7 @@ tea
|
|||
<pre lang="ini"><span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">this.parent.children.filter(F.tags.contains(tag))</span>
|
||||
</pre>
|
||||
<p>You can sort and filter with any expression:</p>
|
||||
<pre lang="ini"><span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">this.parent.children.filter(F.tags.contains(tag) and F.status == 'published').order_by('-pub_date')</span>
|
||||
<pre lang="ini"><span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">this.parent.children.filter(F.tags.contains(tag) and F.status == 'published').order_by('-pub_date')</span>
|
||||
</pre>
|
||||
<p>If the parent page has <a href="https://www.getlektor.com/docs/guides/pagination/" rel="nofollow">a pagination query</a> you may want to use it for tagged pages:</p>
|
||||
<pre lang="ini"><span class="na">items</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">this.parent.pagination.items.filter(F.tags.contains(tag))</span>
|
||||
|
@ -223,7 +223,7 @@ tea
|
|||
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Items:<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">ul</span><span class="p">></span>
|
||||
{% for i in this.items %}
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ i|url }}"</span><span class="p">></span>{{ i._id }}<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ i|url }}"</span><span class="p">></span>{{ i._id }}<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
{% else %}
|
||||
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">em</span><span class="p">></span>No items.<span class="p"></</span><span class="nt">em</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
|
||||
{% endfor %}
|
||||
|
@ -242,27 +242,27 @@ tea
|
|||
<p>Default false. To set true, add this line to <code>tags.ini</code>:</p>
|
||||
<pre lang="ini"><span class="na">ignore_missing</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">true</span>
|
||||
</pre>
|
||||
<p>This allows URLs to missing tag pages to be silently replaced with "". The example use case is if your <code>blog-post.html</code> template includes a statement like:</p>
|
||||
<p>This allows URLs to missing tag pages to be silently replaced with "". The example use case is if your <code>blog-post.html</code> template includes a statement like:</p>
|
||||
<pre lang="html">{% for t in this.tags -%}
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ ('/blog@tag/' ~ t)|url }}"</span><span class="p">></span>{{ t }}<span class="p"></</span><span class="nt">a</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ ('/blog@tag/' ~ t)|url }}"</span><span class="p">></span>{{ t }}<span class="p"></</span><span class="nt">a</span><span class="p">></span>
|
||||
{% endfor %}
|
||||
</pre>
|
||||
<p>If a blog post <em>draft</em> is not discoverable, and it has any new tags used by no published blog posts, then those tag pages do not yet exist. Turn on <code>ignore_missing</code> to allow such drafts to be built. The tag-page URL path will be the empty string "", until the draft is published and the tag page is created.</p>
|
||||
<p>If a blog post <em>draft</em> is not discoverable, and it has any new tags used by no published blog posts, then those tag pages do not yet exist. Turn on <code>ignore_missing</code> to allow such drafts to be built. The tag-page URL path will be the empty string "", until the draft is published and the tag page is created.</p>
|
||||
<h3><code>tags</code></h3>
|
||||
<p>Advanced configuration. An expression for the set of tags. Note that this expression is also useful in a template to get a list of all tags. The default expression is:</p>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">parent.children.distinct("tags")</span>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">parent.children.distinct("tags")</span>
|
||||
</pre>
|
||||
<p>If you set <code>tags_field</code> to a different field name than "tags", the default expression uses your custom field name. For example if you have this line in <code>tags.ini</code>:</p>
|
||||
<p>If you set <code>tags_field</code> to a different field name than "tags", the default expression uses your custom field name. For example if you have this line in <code>tags.ini</code>:</p>
|
||||
<pre lang="ini"><span class="na">tags_field</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">labels</span>
|
||||
</pre>
|
||||
<p>Then the default value of <code>tags</code> is:</p>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">parent.children.distinct("labels")</span>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">parent.children.distinct("labels")</span>
|
||||
</pre>
|
||||
<p>You can use any template expression. For example, if your items have a "published" boolean field, you can select tags of published items:</p>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">parent.children.filter(F.published).distinct("tags")</span>
|
||||
<p>You can use any template expression. For example, if your items have a "published" boolean field, you can select tags of published items:</p>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">parent.children.filter(F.published).distinct("tags")</span>
|
||||
</pre>
|
||||
<p>Or even list your tags manually:</p>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">["tag1", "tag2"]</span>
|
||||
<pre lang="ini"><span class="na">tags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">["tag1", "tag2"]</span>
|
||||
</pre>
|
||||
<p>See <a href="https://www.getlektor.com/docs/api/db/query/" rel="nofollow">the Lektor documentation for queries</a>.</p>
|
||||
<p>Tags are always deduplicated. Tags are sorted in the order listed in the contents.lr / admin, allowing you to control their order manually. Since <code>{{ tags }}</code> simply returns a list, you can always apply any Jinja2 filter on that list such as sort, slice, or rejectattr.</p>
|
||||
|
@ -280,7 +280,7 @@ tea
|
|||
<p>This is the basic weight, used as a base for the following tags.</p>
|
||||
<h4>Example: Tags (with tag count) sorted by tag count (most used first)</h4>
|
||||
<pre lang="jinja"><span class="x"><ul></span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span><span class="o">,</span> <span class="nv">weight</span> <span class="k">in</span> <span class="o">(</span><span class="nv">tagweights</span><span class="o">()</span> <span class="o">|</span> <span class="nf">dictsort</span><span class="o">(</span><span class="nv">by</span><span class="o">=</span><span class="s1">'value'</span><span class="o">,</span> <span class="nv">reverse</span><span class="o">=</span><span class="kp">true</span><span class="o">))</span> <span class="cp">%}</span>
|
||||
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span><span class="o">,</span> <span class="nv">weight</span> <span class="k">in</span> <span class="o">(</span><span class="nv">tagweights</span><span class="o">()</span> <span class="o">|</span> <span class="nf">dictsort</span><span class="o">(</span><span class="nv">by</span><span class="o">=</span><span class="s1">'value'</span><span class="o">,</span> <span class="nv">reverse</span><span class="o">=</span><span class="kp">true</span><span class="o">))</span> <span class="cp">%}</span>
|
||||
<span class="x"> <li></span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span><span class="x"> (</span><span class="cp">{{</span> <span class="nv">weight.count</span> <span class="cp">}}</span><span class="x"> articles).</li></span>
|
||||
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
|
||||
<span class="x"></ul></span>
|
||||
|
@ -297,8 +297,8 @@ tea
|
|||
<h4>Example: Most used tag is twice as big as least used tag</h4>
|
||||
<pre lang="jinja"><span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span><span class="o">,</span> <span class="nv">weight</span> <span class="k">in</span> <span class="nv">tagweights</span><span class="o">()|</span><span class="nf">dictsort</span> <span class="cp">%}</span>
|
||||
<span class="x"><a</span>
|
||||
<span class="x"> href="</span><span class="cp">{{</span> <span class="o">(</span><span class="s1">'/blog@tag/'</span> <span class="o">~</span> <span class="nv">tag</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="x">"</span>
|
||||
<span class="x"> style="font-size: </span><span class="cp">{{</span> <span class="nv">weight.log</span><span class="o">(</span><span class="m">100</span><span class="o">,</span> <span class="m">200</span><span class="o">)|</span><span class="nf">round</span><span class="o">|</span><span class="nf">int</span> <span class="cp">}}</span><span class="x">%;"</span>
|
||||
<span class="x"> href="</span><span class="cp">{{</span> <span class="o">(</span><span class="s1">'/blog@tag/'</span> <span class="o">~</span> <span class="nv">tag</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="x">"</span>
|
||||
<span class="x"> style="font-size: </span><span class="cp">{{</span> <span class="nv">weight.log</span><span class="o">(</span><span class="m">100</span><span class="o">,</span> <span class="m">200</span><span class="o">)|</span><span class="nf">round</span><span class="o">|</span><span class="nf">int</span> <span class="cp">}}</span><span class="x">%;"</span>
|
||||
<span class="x"> ></span>
|
||||
<span class="x"> </span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span>
|
||||
<span class="x"> </a></span>
|
||||
|
@ -314,8 +314,8 @@ tea
|
|||
<h4>Example: Tags are given CSS classes <code>tagcloud-tiny</code>, <code>tagcloud-small</code>, etc.</h4>
|
||||
<pre lang="jinja"><span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span><span class="o">,</span> <span class="nv">weight</span> <span class="k">in</span> <span class="nv">tagweights</span><span class="o">()|</span><span class="nf">dictsort</span> <span class="cp">%}</span>
|
||||
<span class="x"><a</span>
|
||||
<span class="x"> href="</span><span class="cp">{{</span> <span class="o">(</span><span class="s1">'/blog@tag/'</span> <span class="o">~</span> <span class="nv">tag</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="x">"</span>
|
||||
<span class="x"> class="tagcloud-</span><span class="cp">{{</span> <span class="nv">weight.loggroup</span><span class="o">([</span><span class="s2">"tiny"</span><span class="o">,</span> <span class="s2">"small"</span><span class="o">,</span> <span class="s2">"normal"</span><span class="o">,</span> <span class="s2">"big"</span><span class="o">,</span> <span class="s2">"large"</span><span class="o">])</span> <span class="cp">}}</span><span class="x">"</span>
|
||||
<span class="x"> href="</span><span class="cp">{{</span> <span class="o">(</span><span class="s1">'/blog@tag/'</span> <span class="o">~</span> <span class="nv">tag</span><span class="o">)|</span><span class="nf">url</span> <span class="cp">}}</span><span class="x">"</span>
|
||||
<span class="x"> class="tagcloud-</span><span class="cp">{{</span> <span class="nv">weight.loggroup</span><span class="o">([</span><span class="s2">"tiny"</span><span class="o">,</span> <span class="s2">"small"</span><span class="o">,</span> <span class="s2">"normal"</span><span class="o">,</span> <span class="s2">"big"</span><span class="o">,</span> <span class="s2">"large"</span><span class="o">])</span> <span class="cp">}}</span><span class="x">"</span>
|
||||
<span class="x"> ></span>
|
||||
<span class="x"> </span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span>
|
||||
<span class="x"> </a></span>
|
||||
|
|
|
@ -144,7 +144,7 @@ $<span class="w"> </span>lektor<span class="w"> </span>plugin<span class="w"> </
|
|||
<p>Configure your template paths</p>
|
||||
<p>In <code>tailwindcss.config.js</code>:</p>
|
||||
<pre lang="javascript"><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">content</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s1">'./templates/**/*.{html,j2}'</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">content</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s1">'./templates/**/*.{html,j2}'</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">theme</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">extend</span><span class="o">:</span><span class="w"> </span><span class="p">{},</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
|
|
|
@ -135,7 +135,7 @@ content, but still want thumbnails to be generated for the link itself. For
|
|||
example, you may have an image called <code>cat.jpg</code>, and to link to it in the
|
||||
<em>content</em> (not the template), but also show a thumbnail.</p>
|
||||
<p>You can do that like so:</p>
|
||||
<pre><code><a href="cat.jpg"><img src="cat-small.jpg" /></a>
|
||||
<pre><code><a href="cat.jpg"><img src="cat-small.jpg" /></a>
|
||||
</code></pre>
|
||||
<h2>Installation</h2>
|
||||
<p>To install the plugin, just add <code>lektor-thumbnail-generator</code> to your plugins
|
||||
|
|
|
@ -138,34 +138,34 @@
|
|||
These files will then be copied over to Lektors templates folder so that they can be used by Lektor.
|
||||
This plugin depends on the <a href="https://github.com/lektor/lektor-webpack-support" rel="nofollow">lektor-webpack-support</a> plugin to be really useful.</p>
|
||||
<h1>webpack/webpack.config.js</h1>
|
||||
<pre lang="js"><span class="kd">const</span><span class="w"> </span><span class="nx">path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"path"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"mini-css-extract-plugin"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="nx">HtmlWebpackPlugin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"html-webpack-plugin"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">CleanWebpackPlugin</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"clean-webpack-plugin"</span><span class="p">);</span>
|
||||
<pre lang="js"><span class="kd">const</span><span class="w"> </span><span class="nx">path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"path"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"mini-css-extract-plugin"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="nx">HtmlWebpackPlugin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"html-webpack-plugin"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nx">CleanWebpackPlugin</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"clean-webpack-plugin"</span><span class="p">);</span>
|
||||
|
||||
|
||||
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"production"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"production"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">entry</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">main</span><span class="o">:</span><span class="w"> </span><span class="s2">"./src/index.js"</span>
|
||||
<span class="w"> </span><span class="nx">main</span><span class="o">:</span><span class="w"> </span><span class="s2">"./src/index.js"</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nx">output</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"[name].bundle.js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">path</span><span class="o">:</span><span class="w"> </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"/assets/generated"</span><span class="w"> </span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"[name].bundle.js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">path</span><span class="o">:</span><span class="w"> </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"/assets/generated"</span><span class="w"> </span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nx">optimization</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">minimizer</span><span class="o">:</span><span class="w"> </span><span class="p">[</span>
|
||||
<span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">HtmlWebpackPlugin</span><span class="p">({</span>
|
||||
<span class="w"> </span><span class="nx">inject</span><span class="o">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"layout_generated.html"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">template</span><span class="o">:</span><span class="w"> </span><span class="s2">"./src/layout_template.html"</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"layout_generated.html"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">template</span><span class="o">:</span><span class="w"> </span><span class="s2">"./src/layout_template.html"</span>
|
||||
<span class="w"> </span><span class="p">})</span>
|
||||
<span class="w"> </span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nx">plugins</span><span class="o">:</span><span class="w"> </span><span class="p">[</span>
|
||||
<span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">CleanWebpackPlugin</span><span class="p">(),</span>
|
||||
<span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="p">({</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"[name].css"</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"[name].css"</span>
|
||||
<span class="w"> </span><span class="p">})</span>
|
||||
<span class="w"> </span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">module</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
|
@ -173,8 +173,8 @@ This plugin depends on the <a href="https://github.com/lektor/lektor-webpack-sup
|
|||
<span class="w"> </span><span class="nx">test</span><span class="o">:</span><span class="w"> </span><span class="sr">/\.scss$/</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span>
|
||||
<span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="p">.</span><span class="nx">loader</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="s2">"css-loader"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="s2">"sass-loader"</span>
|
||||
<span class="w"> </span><span class="s2">"css-loader"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="s2">"sass-loader"</span>
|
||||
<span class="w"> </span><span class="p">]</span>
|
||||
<span class="w"> </span><span class="p">}]</span>
|
||||
<span class="w"> </span><span class="p">}</span>
|
||||
|
@ -182,16 +182,16 @@ This plugin depends on the <a href="https://github.com/lektor/lektor-webpack-sup
|
|||
</pre>
|
||||
<h1>webpack/src/layout_template.html</h1>
|
||||
<pre lang="html"><span class="cp"><!DOCTYPE html></span>
|
||||
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
|
||||
|
||||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"UTF-8"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"viewport"</span> <span class="na">content</span><span class="o">=</span><span class="s">"width=device-width, initial-scale=1.0"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">"X-UA-Compatible"</span> <span class="na">content</span><span class="o">=</span><span class="s">"ie=edge"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"UTF-8"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"viewport"</span> <span class="na">content</span><span class="o">=</span><span class="s">"width=device-width, initial-scale=1.0"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">"X-UA-Compatible"</span> <span class="na">content</span><span class="o">=</span><span class="s">"ie=edge"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">title</span><span class="p">></span>{{ this.title }} <span class="ni">&middot;</span> {{ config.PROJECT.name }} <span class="p"></</span><span class="nt">title</span><span class="p">></span>
|
||||
|
||||
<span class="err"><</span>% for (var css in htmlWebpackPlugin.files.css) { %>
|
||||
<span class="p"><</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ '/generated/<%= htmlWebpackPlugin.files.css[css] %>' | asseturl }}"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ '/generated/<%= htmlWebpackPlugin.files.css[css] %>' | asseturl }}"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">></span>
|
||||
<span class="err"><</span>% } %>
|
||||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||||
|
||||
|
@ -202,7 +202,7 @@ This plugin depends on the <a href="https://github.com/lektor/lektor-webpack-sup
|
|||
<span class="p"></</span><span class="nt">main</span><span class="p">></span>
|
||||
|
||||
<span class="err"><</span>% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
|
||||
<span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ '/generated/<%= htmlWebpackPlugin.files.chunks[chunk].entry %>' | asseturl }}"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ '/generated/<%= htmlWebpackPlugin.files.chunks[chunk].entry %>' | asseturl }}"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span>
|
||||
<span class="err"><</span>% } %>
|
||||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||||
|
||||
|
|
|
@ -163,9 +163,9 @@ inside that folder create <code>package.json</code> and a <code>webpack.config.j
|
|||
start is to create an almost empty file (name and version fields are mandatory
|
||||
but not important for functionality, change them to suit your own needs):</p>
|
||||
<pre lang="json"><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"lektor-webpack"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.0.0"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"private"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span>
|
||||
<span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"lektor-webpack"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"version"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1.0.0"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nt">"private"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span>
|
||||
<span class="p">}</span>
|
||||
</pre>
|
||||
<p>Now we can <code>npm install</code> (or <code>yarn add</code>) the rest:</p>
|
||||
|
@ -182,42 +182,42 @@ setup that's good enough to cover most things you will encounter. The
|
|||
idea is to build the files from <code>webpack/scss</code> and <code>webpack/js</code> into
|
||||
<code>assets/static/gen</code> so that we can use it even if we do not have webpack
|
||||
installed for as long as someone else ran it before.</p>
|
||||
<pre lang="javascript"><span class="kd">const</span><span class="w"> </span><span class="nx">path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"path"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"mini-css-extract-plugin"</span><span class="p">);</span>
|
||||
<pre lang="javascript"><span class="kd">const</span><span class="w"> </span><span class="nx">path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"path"</span><span class="p">);</span>
|
||||
<span class="kd">const</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s2">"mini-css-extract-plugin"</span><span class="p">);</span>
|
||||
|
||||
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">entry</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">app</span><span class="o">:</span><span class="w"> </span><span class="s2">"./js/main.js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">styles</span><span class="o">:</span><span class="w"> </span><span class="s2">"./scss/main.scss"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">app</span><span class="o">:</span><span class="w"> </span><span class="s2">"./js/main.js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">styles</span><span class="o">:</span><span class="w"> </span><span class="s2">"./scss/main.scss"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nx">output</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">path</span><span class="o">:</span><span class="w"> </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">),</span><span class="w"> </span><span class="s2">"assets"</span><span class="p">,</span><span class="w"> </span><span class="s2">"static"</span><span class="p">,</span><span class="w"> </span><span class="s2">"gen"</span><span class="p">),</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"[name].js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">path</span><span class="o">:</span><span class="w"> </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">),</span><span class="w"> </span><span class="s2">"assets"</span><span class="p">,</span><span class="w"> </span><span class="s2">"static"</span><span class="p">,</span><span class="w"> </span><span class="s2">"gen"</span><span class="p">),</span>
|
||||
<span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"[name].js"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nx">devtool</span><span class="o">:</span><span class="w"> </span><span class="s2">"source-map"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"production"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">devtool</span><span class="o">:</span><span class="w"> </span><span class="s2">"source-map"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">mode</span><span class="o">:</span><span class="w"> </span><span class="s2">"production"</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">module</span><span class="o">:</span><span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">rules</span><span class="o">:</span><span class="w"> </span><span class="p">[</span>
|
||||
<span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">test</span><span class="o">:</span><span class="w"> </span><span class="sr">/\.js$/</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">exclude</span><span class="o">:</span><span class="w"> </span><span class="sr">/node_modules/</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"babel-loader"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"babel-loader"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">test</span><span class="o">:</span><span class="w"> </span><span class="sr">/\.scss$/</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">MiniCssExtractPlugin</span><span class="p">.</span><span class="nx">loader</span><span class="p">,</span><span class="w"> </span><span class="s2">"css-loader"</span><span class="p">,</span><span class="w"> </span><span class="s2">"sass-loader"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">MiniCssExtractPlugin</span><span class="p">.</span><span class="nx">loader</span><span class="p">,</span><span class="w"> </span><span class="s2">"css-loader"</span><span class="p">,</span><span class="w"> </span><span class="s2">"sass-loader"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">test</span><span class="o">:</span><span class="w"> </span><span class="sr">/\.css$/</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">MiniCssExtractPlugin</span><span class="p">.</span><span class="nx">loader</span><span class="p">,</span><span class="w"> </span><span class="s2">"css-loader"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="nx">MiniCssExtractPlugin</span><span class="p">.</span><span class="nx">loader</span><span class="p">,</span><span class="w"> </span><span class="s2">"css-loader"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="p">{</span>
|
||||
<span class="w"> </span><span class="nx">test</span><span class="o">:</span><span class="w"> </span><span class="sr">/\.(woff2?|ttf|eot|svg|png|jpe?g|gif)$/</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"file"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="nx">use</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"file"</span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="p">],</span>
|
||||
<span class="w"> </span><span class="p">},</span>
|
||||
<span class="w"> </span><span class="nx">plugins</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="ow">new</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="p">({</span><span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"styles.css"</span><span class="w"> </span><span class="p">})],</span>
|
||||
<span class="w"> </span><span class="nx">plugins</span><span class="o">:</span><span class="w"> </span><span class="p">[</span><span class="ow">new</span><span class="w"> </span><span class="nx">MiniCssExtractPlugin</span><span class="p">({</span><span class="w"> </span><span class="nx">filename</span><span class="o">:</span><span class="w"> </span><span class="s2">"styles.css"</span><span class="w"> </span><span class="p">})],</span>
|
||||
<span class="p">};</span>
|
||||
</pre>
|
||||
<h2>Creating the App</h2>
|
||||
|
@ -238,8 +238,8 @@ Lektor website that uses webpack.</p>
|
|||
<code>lektor build -f webpack</code>.</p>
|
||||
<h2>Including The Files</h2>
|
||||
<p>Now you need to include the files in your template. This will do it:</p>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ '/static/gen/styles.css'|asseturl }}"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">text/javascript</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ '/static/gen/app.js'|asseturl }}"</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span>
|
||||
<pre lang="html"><span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ '/static/gen/styles.css'|asseturl }}"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">text/javascript</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ '/static/gen/app.js'|asseturl }}"</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></</span><span class="nt">script</span><span class="p">></span>
|
||||
</pre>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue