diff --git a/.env b/.env
index 2b3cf00..29713c1 100644
--- a/.env
+++ b/.env
@@ -1,3 +1,4 @@
#THEME=https://raw.githubusercontent.com/colineckert/obsidian-things/main/obsidian.css
#THEME=https://github.com/kepano/obsidian-minimal/blob/master/obsidian.css
-#BASE_THEME=light
\ No newline at end of file
+#BASE_THEME=light
+dgHomeLink=true
\ No newline at end of file
diff --git a/src/site/_data/meta.js b/src/site/_data/meta.js
index a5d02e1..3b02e6d 100644
--- a/src/site/_data/meta.js
+++ b/src/site/_data/meta.js
@@ -8,11 +8,12 @@ module.exports = async() => {
const res = await axios.get(process.env.THEME)
themeStyle = ``;
}
- return {
+ const meta ={
env: process.env.ELEVENTY_ENV,
theme: process.env.THEME,
themeStyle: themeStyle,
- baseTheme: process.env.BASE_THEME || "dark"
- }
+ baseTheme: process.env.BASE_THEME || "dark",
+ };
+ return meta;
};
diff --git a/src/site/_includes/components/sidebar.njk b/src/site/_includes/components/sidebar.njk
index b33256e..9cfce89 100644
--- a/src/site/_includes/components/sidebar.njk
+++ b/src/site/_includes/components/sidebar.njk
@@ -14,14 +14,14 @@
- {%if dgShowLocalGraph === true %}
+ {%if settings.dgShowLocalGraph === true %}
{%include "components/graphScript.njk"%}
{% endif %}
@@ -47,7 +47,7 @@
document.addEventListener('alpine:init', () => {
const isDesktop = window.innerWidth >= 1100;
- {% if dgShowLocalGraph === true %}
+ {% if settings.dgShowLocalGraph === true %}
renderGraph(600, 400);
{% endif %}
diff --git a/src/site/_includes/layouts/note.njk b/src/site/_includes/layouts/note.njk
index ca7bf53..a05156c 100644
--- a/src/site/_includes/layouts/note.njk
+++ b/src/site/_includes/layouts/note.njk
@@ -12,15 +12,16 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
{%include "components/notegrowthhistory.njk"%}
- {% if dgHomeLink !== false%}
+ {% if settings.dgHomeLink !== false%}
🏡 Back Home
{% endif %}
- {% if dgShowInlineTitle === true %}
+ {# Dra dette opp i en egen greie for hver setting. Definer disse settingene i en klasse og lag en settings.js lik meta.js. Gå gjennom hver key og kjør denne logikken for å sette den. #}
+ {% if settings.dgShowInlineTitle === true %}
{{ page.fileSlug }}
{% endif %}
{{ content | link | highlight | safe}}
- {% if dgShowBacklinks === true or dgShowLocalGraph === true%}
+ {% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true%}
{%include "components/sidebar.njk"%}
{% endif %}
diff --git a/src/site/index.11tydata.js b/src/site/index.11tydata.js
index 8f3616b..1876f3f 100644
--- a/src/site/index.11tydata.js
+++ b/src/site/index.11tydata.js
@@ -1,15 +1,25 @@
+require("dotenv").config();
const wikilink = /\[\[(.*?\|.*?)\]\]/g
function caselessCompare(a, b) {
return a.toLowerCase() === b.toLowerCase();
}
+//Duplicated in notes.11tydata.js because new files means I need to update the plugin
+const allSettings = [
+ "dgHomeLink",
+ "dgPassFrontmatter",
+ "dgShowBacklinks",
+ "dgShowLocalGraph",
+ "dgShowInlineTitle"
+];
+
module.exports = {
eleventyComputed: {
backlinks: (data) => {
const notes = data.collections.note;
- if(!notes){
+ if (!notes) {
return [];
}
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
@@ -45,12 +55,12 @@ module.exports = {
outbound: (data) => {
const notes = data.collections.note;
- if(!notes || notes.length == 0){
+ if (!notes || notes.length == 0) {
return [];
}
const currentNote = data.collections.gardenEntry && data.collections.gardenEntry[0];
- if(!currentNote){
+ if (!currentNote) {
return [];
}
@@ -68,7 +78,7 @@ module.exports = {
let outbound = outboundLinks.map(fileslug => {
var outboundNote = notes.find(x => caselessCompare(x.data.page.filePathStem.replace("/notes/", ""), fileslug));
- if(!outboundNote){
+ if (!outboundNote) {
return null;
}
@@ -77,25 +87,33 @@ module.exports = {
title: outboundNote.data.page.fileSlug,
id: counter++
}
- }).filter(x=>x);
+ }).filter(x => x);
return outbound;
},
- dgShowLocalGraph: (data) => {
- const currentNote = data.collections.gardenEntry && data.collections.gardenEntry[0];
- if(currentNote && currentNote.data && currentNote.data.dgShowLocalGraph){
- return true;
- }
-
- return false;
- },
- dgShowBacklinks: (data) =>{
+ settings: (data) => {
const currentnote = data.collections.gardenEntry && data.collections.gardenEntry[0];
- if(currentnote && currentnote.data && currentnote.data.dgShowLocalGraph){
- return true;
+ if (currentnote && currentnote.data) {
+ const noteSettings = {};
+ allSettings.forEach(setting => {
+ let noteSetting = currentnote.data[setting];
+ let globalSetting = process.env[setting];
+
+ let settingValue = (noteSetting || (globalSetting === 'true' && noteSetting !== false));
+ noteSettings[setting] = settingValue;
+ });
+ return noteSettings;
+
}
- return false;
+ return {};
+ },
+ noteTitle: (data) => {
+ const currentnote = data.collections.gardenEntry && data.collections.gardenEntry[0];
+ if (currentnote && currentnote.data) {
+ return currentnote.data.page.fileSlug;
+ }
+ return "";
}
}
}
\ No newline at end of file
diff --git a/src/site/index.njk b/src/site/index.njk
index c2de056..96e09dc 100644
--- a/src/site/index.njk
+++ b/src/site/index.njk
@@ -1,22 +1,22 @@
-
- {% if collections.gardenEntry[0].data.dgShowInlineTitle === true %}
-
{{ collections.gardenEntry[0].fileSlug }}
+ {% if settings.dgShowInlineTitle === true %}
+ {{ noteTitle }}
{% endif %}
{%- for garden in collections.gardenEntry -%}
{{garden.templateContent | link | highlight | safe }}
{%- endfor -%}
- {%if collections.gardenEntry[0].data.dgShowBacklinks === true or collections.gardenEntry[0].data.dgShowLocalGraph === true%}
+ {%if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true%}
{%include "components/sidebar.njk" %}
{%endif%}
diff --git a/src/site/notes/notes.11tydata.js b/src/site/notes/notes.11tydata.js
index c8adedd..e72838e 100644
--- a/src/site/notes/notes.11tydata.js
+++ b/src/site/notes/notes.11tydata.js
@@ -1,15 +1,26 @@
+require("dotenv").config();
+
const wikilink = /\[\[(.*?\|.*?)\]\]/g
function caselessCompare(a, b) {
return a.toLowerCase() === b.toLowerCase();
}
+//Duplicated in index.11tydata.js because new files means I need to update the plugin
+const allSettings = [
+ "dgHomeLink",
+ "dgPassFrontmatter",
+ "dgShowBacklinks",
+ "dgShowLocalGraph",
+ "dgShowInlineTitle"
+];
+
module.exports = {
eleventyComputed: {
backlinks: (data) => {
const notes = data.collections.note;
- if(!notes){
+ if (!notes) {
return [];
}
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
@@ -46,12 +57,12 @@ module.exports = {
const notes = data.collections.note;
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
- if(!notes || notes.length == 0){
+ if (!notes || notes.length == 0) {
return [];
}
- const currentNote = notes.find(x =>x.data.page.filePathStem && caselessCompare(x.data.page.filePathStem.replace('/notes/', ''), currentFileSlug));
- if(!currentNote){
+ const currentNote = notes.find(x => x.data.page.filePathStem && caselessCompare(x.data.page.filePathStem.replace('/notes/', ''), currentFileSlug));
+ if (!currentNote) {
return [];
}
@@ -68,7 +79,7 @@ module.exports = {
let outbound = outboundLinks.map(fileslug => {
var outboundNote = notes.find(x => caselessCompare(x.data.page.filePathStem.replace("/notes/", ""), fileslug));
- if(!outboundNote){
+ if (!outboundNote) {
return null;
}
@@ -77,10 +88,21 @@ module.exports = {
title: outboundNote.data.page.fileSlug,
id: counter++
}
- }).filter(x=>x);
+ }).filter(x => x);
return outbound;
- }
+ },
+ settings: (data) => {
+ const noteSettings = {};
+ allSettings.forEach(setting => {
+ let noteSetting = data[setting];
+ let globalSetting = process.env[setting];
+
+ let settingValue = (noteSetting || (globalSetting === 'true' && noteSetting !== false));
+ noteSettings[setting] = settingValue;
+ });
+ return noteSettings;
+ }
}
}
\ No newline at end of file