Use dghomelink as toggle for navbar

This commit is contained in:
Ole Eskild Steensen 2022-11-07 13:34:19 +01:00
parent eee9e9aa5f
commit 9f477fb3ab
2 changed files with 25 additions and 14 deletions

View File

@ -1,4 +1,5 @@
<nav class="navbar"> {%if settings.dgHomeLink === true%}
<nav class="navbar">
<div class="navbar-inner"> <div class="navbar-inner">
<a href="/" style="text-decoration: none;"> <a href="/" style="text-decoration: none;">
<h1>{{meta.siteName}}</h1> <h1>{{meta.siteName}}</h1>
@ -7,4 +8,11 @@
{% if settings.dgEnableSearch === true%} {% if settings.dgEnableSearch === true%}
{% include "components/searchButton.njk" %} {% include "components/searchButton.njk" %}
{%endif%} {%endif%}
</nav> </nav>
{%else%}
<div class="empty-navbar" >
{% if settings.dgEnableSearch === true%}
{% include "components/searchButton.njk" %}
{%endif%}
</div>
{%endif%}

View File

@ -1,20 +1,23 @@
require("dotenv").config()
const lunrjs = require('lunr'); const lunrjs = require('lunr');
const path = require('path'); const path = require('path');
function createIndex(posts) { function createIndex(posts) {
return lunrjs(function() { return lunrjs(function () {
this.ref('id'); this.ref('id');
this.field('title'); this.field('title');
this.field('content'); this.field('content');
this.field('date'); this.field('date');
posts.forEach((p,idx) => { posts.forEach((p, idx) => {
p.id = idx; p.id = idx;
this.add(p); this.add(p);
}); });
}); });
} }
const data = require('../../netlify/functions/search/data.json'); if (process.env.dgEnableSearch) {
const index = createIndex(data); const data = require('../../netlify/functions/search/data.json');
require('fs').writeFileSync(path.join(__dirname, '../../netlify/functions/search/index.json'), JSON.stringify(index)); const index = createIndex(data);
require('fs').writeFileSync(path.join(__dirname, '../../netlify/functions/search/index.json'), JSON.stringify(index));
}