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

View File

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