mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-06 04:35:20 +00:00
Use default note setting from .env
This commit is contained in:
parent
43d0d01b61
commit
b2b5253f30
3
.env
3
.env
@ -1,3 +1,4 @@
|
|||||||
#THEME=https://raw.githubusercontent.com/colineckert/obsidian-things/main/obsidian.css
|
#THEME=https://raw.githubusercontent.com/colineckert/obsidian-things/main/obsidian.css
|
||||||
#THEME=https://github.com/kepano/obsidian-minimal/blob/master/obsidian.css
|
#THEME=https://github.com/kepano/obsidian-minimal/blob/master/obsidian.css
|
||||||
#BASE_THEME=light
|
#BASE_THEME=light
|
||||||
|
dgHomeLink=true
|
@ -8,11 +8,12 @@ module.exports = async() => {
|
|||||||
const res = await axios.get(process.env.THEME)
|
const res = await axios.get(process.env.THEME)
|
||||||
themeStyle = `<style>${res.data}</style>`;
|
themeStyle = `<style>${res.data}</style>`;
|
||||||
}
|
}
|
||||||
return {
|
const meta ={
|
||||||
env: process.env.ELEVENTY_ENV,
|
env: process.env.ELEVENTY_ENV,
|
||||||
theme: process.env.THEME,
|
theme: process.env.THEME,
|
||||||
themeStyle: themeStyle,
|
themeStyle: themeStyle,
|
||||||
baseTheme: process.env.BASE_THEME || "dark"
|
baseTheme: process.env.BASE_THEME || "dark",
|
||||||
}
|
};
|
||||||
|
|
||||||
|
return meta;
|
||||||
};
|
};
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
|
|
||||||
<div x-show="open || !isDesktop" class="sidebar-container" style="display: none;">
|
<div x-show="open || !isDesktop" class="sidebar-container" style="display: none;">
|
||||||
|
|
||||||
{%if dgShowLocalGraph === true%}
|
{%if settings.dgShowLocalGraph === true%}
|
||||||
<div x-show="isDesktop">
|
<div x-show="isDesktop">
|
||||||
<h3>Graph</h3>
|
<h3>Graph</h3>
|
||||||
<div id="link-graph" style="margin-bottom:20px; background-color: var(--background-primary); border-radius: 10px; width: fit-content;"></div>
|
<div id="link-graph" style="margin-bottom:20px; background-color: var(--background-primary); border-radius: 10px; width: fit-content;"></div>
|
||||||
</div>
|
</div>
|
||||||
{%endif%}
|
{%endif%}
|
||||||
|
|
||||||
{%if dgShowBacklinks === true %}
|
{%if settings.dgShowBacklinks === true %}
|
||||||
<h3>Links to this page</h3>
|
<h3>Links to this page</h3>
|
||||||
{%- if backlinks.length === 0 -%}
|
{%- if backlinks.length === 0 -%}
|
||||||
<div class="backlink-card">
|
<div class="backlink-card">
|
||||||
@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{%if dgShowLocalGraph === true %}
|
{%if settings.dgShowLocalGraph === true %}
|
||||||
{%include "components/graphScript.njk"%}
|
{%include "components/graphScript.njk"%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@
|
|||||||
document.addEventListener('alpine:init', () => {
|
document.addEventListener('alpine:init', () => {
|
||||||
|
|
||||||
const isDesktop = window.innerWidth >= 1100;
|
const isDesktop = window.innerWidth >= 1100;
|
||||||
{% if dgShowLocalGraph === true %}
|
{% if settings.dgShowLocalGraph === true %}
|
||||||
renderGraph(600, 400);
|
renderGraph(600, 400);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -12,15 +12,16 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
|
|||||||
{%include "components/notegrowthhistory.njk"%}
|
{%include "components/notegrowthhistory.njk"%}
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{% if dgHomeLink !== false%}
|
{% if settings.dgHomeLink !== false%}
|
||||||
<a href="/">🏡 Back Home</a>
|
<a href="/">🏡 Back Home</a>
|
||||||
{% endif %}
|
{% 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 %}
|
||||||
<h1>{{ page.fileSlug }}</h1>
|
<h1>{{ page.fileSlug }}</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ content | link | highlight | safe}}
|
{{ content | link | highlight | safe}}
|
||||||
|
|
||||||
{% if dgShowBacklinks === true or dgShowLocalGraph === true%}
|
{% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true%}
|
||||||
{%include "components/sidebar.njk"%}
|
{%include "components/sidebar.njk"%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
|
|
||||||
|
require("dotenv").config();
|
||||||
const wikilink = /\[\[(.*?\|.*?)\]\]/g
|
const wikilink = /\[\[(.*?\|.*?)\]\]/g
|
||||||
|
|
||||||
function caselessCompare(a, b) {
|
function caselessCompare(a, b) {
|
||||||
return a.toLowerCase() === b.toLowerCase();
|
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 = {
|
module.exports = {
|
||||||
eleventyComputed: {
|
eleventyComputed: {
|
||||||
backlinks: (data) => {
|
backlinks: (data) => {
|
||||||
const notes = data.collections.note;
|
const notes = data.collections.note;
|
||||||
if(!notes){
|
if (!notes) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
|
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
|
||||||
@ -45,12 +55,12 @@ module.exports = {
|
|||||||
outbound: (data) => {
|
outbound: (data) => {
|
||||||
const notes = data.collections.note;
|
const notes = data.collections.note;
|
||||||
|
|
||||||
if(!notes || notes.length == 0){
|
if (!notes || notes.length == 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentNote = data.collections.gardenEntry && data.collections.gardenEntry[0];
|
const currentNote = data.collections.gardenEntry && data.collections.gardenEntry[0];
|
||||||
if(!currentNote){
|
if (!currentNote) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +78,7 @@ module.exports = {
|
|||||||
|
|
||||||
let outbound = outboundLinks.map(fileslug => {
|
let outbound = outboundLinks.map(fileslug => {
|
||||||
var outboundNote = notes.find(x => caselessCompare(x.data.page.filePathStem.replace("/notes/", ""), fileslug));
|
var outboundNote = notes.find(x => caselessCompare(x.data.page.filePathStem.replace("/notes/", ""), fileslug));
|
||||||
if(!outboundNote){
|
if (!outboundNote) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,25 +87,33 @@ module.exports = {
|
|||||||
title: outboundNote.data.page.fileSlug,
|
title: outboundNote.data.page.fileSlug,
|
||||||
id: counter++
|
id: counter++
|
||||||
}
|
}
|
||||||
}).filter(x=>x);
|
}).filter(x => x);
|
||||||
|
|
||||||
return outbound;
|
return outbound;
|
||||||
|
|
||||||
},
|
},
|
||||||
dgShowLocalGraph: (data) => {
|
settings: (data) => {
|
||||||
const currentNote = data.collections.gardenEntry && data.collections.gardenEntry[0];
|
|
||||||
if(currentNote && currentNote.data && currentNote.data.dgShowLocalGraph){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
dgShowBacklinks: (data) =>{
|
|
||||||
const currentnote = data.collections.gardenEntry && data.collections.gardenEntry[0];
|
const currentnote = data.collections.gardenEntry && data.collections.gardenEntry[0];
|
||||||
if(currentnote && currentnote.data && currentnote.data.dgShowLocalGraph){
|
if (currentnote && currentnote.data) {
|
||||||
return true;
|
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 "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,22 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>{{ collections.gardenEntry[0].fileSlug }}</title>
|
<title>{{ noteTitle }}</title>
|
||||||
{%include "components/pageheader.njk"%}
|
{%include "components/pageheader.njk"%}
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-{{meta.baseTheme}} markdown-preview-view markdown-rendered">
|
<body class="theme-{{meta.baseTheme}} markdown-preview-view markdown-rendered">
|
||||||
{%include "components/notegrowthhistory.njk"%}
|
{%include "components/notegrowthhistory.njk"%}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
{% if collections.gardenEntry[0].data.dgShowInlineTitle === true %}
|
{% if settings.dgShowInlineTitle === true %}
|
||||||
<h1>{{ collections.gardenEntry[0].fileSlug }}</h1>
|
<h1>{{ noteTitle }}</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- for garden in collections.gardenEntry -%}
|
{%- for garden in collections.gardenEntry -%}
|
||||||
{{garden.templateContent | link | highlight | safe }}
|
{{garden.templateContent | link | highlight | safe }}
|
||||||
{%- endfor -%}
|
{%- 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" %}
|
{%include "components/sidebar.njk" %}
|
||||||
{%endif%}
|
{%endif%}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,26 @@
|
|||||||
|
|
||||||
|
require("dotenv").config();
|
||||||
|
|
||||||
const wikilink = /\[\[(.*?\|.*?)\]\]/g
|
const wikilink = /\[\[(.*?\|.*?)\]\]/g
|
||||||
|
|
||||||
function caselessCompare(a, b) {
|
function caselessCompare(a, b) {
|
||||||
return a.toLowerCase() === b.toLowerCase();
|
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 = {
|
module.exports = {
|
||||||
eleventyComputed: {
|
eleventyComputed: {
|
||||||
backlinks: (data) => {
|
backlinks: (data) => {
|
||||||
const notes = data.collections.note;
|
const notes = data.collections.note;
|
||||||
if(!notes){
|
if (!notes) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
|
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
|
||||||
@ -46,12 +57,12 @@ module.exports = {
|
|||||||
const notes = data.collections.note;
|
const notes = data.collections.note;
|
||||||
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
|
const currentFileSlug = data.page.filePathStem.replace('/notes/', '');
|
||||||
|
|
||||||
if(!notes || notes.length == 0){
|
if (!notes || notes.length == 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentNote = notes.find(x =>x.data.page.filePathStem && caselessCompare(x.data.page.filePathStem.replace('/notes/', ''), currentFileSlug));
|
const currentNote = notes.find(x => x.data.page.filePathStem && caselessCompare(x.data.page.filePathStem.replace('/notes/', ''), currentFileSlug));
|
||||||
if(!currentNote){
|
if (!currentNote) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +79,7 @@ module.exports = {
|
|||||||
|
|
||||||
let outbound = outboundLinks.map(fileslug => {
|
let outbound = outboundLinks.map(fileslug => {
|
||||||
var outboundNote = notes.find(x => caselessCompare(x.data.page.filePathStem.replace("/notes/", ""), fileslug));
|
var outboundNote = notes.find(x => caselessCompare(x.data.page.filePathStem.replace("/notes/", ""), fileslug));
|
||||||
if(!outboundNote){
|
if (!outboundNote) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,10 +88,21 @@ module.exports = {
|
|||||||
title: outboundNote.data.page.fileSlug,
|
title: outboundNote.data.page.fileSlug,
|
||||||
id: counter++
|
id: counter++
|
||||||
}
|
}
|
||||||
}).filter(x=>x);
|
}).filter(x => x);
|
||||||
|
|
||||||
return outbound;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user