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
1
.env
1
.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
|
||||
dgHomeLink=true
|
@ -8,11 +8,12 @@ module.exports = async() => {
|
||||
const res = await axios.get(process.env.THEME)
|
||||
themeStyle = `<style>${res.data}</style>`;
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
@ -14,14 +14,14 @@
|
||||
|
||||
<div x-show="open || !isDesktop" class="sidebar-container" style="display: none;">
|
||||
|
||||
{%if dgShowLocalGraph === true%}
|
||||
{%if settings.dgShowLocalGraph === true%}
|
||||
<div x-show="isDesktop">
|
||||
<h3>Graph</h3>
|
||||
<div id="link-graph" style="margin-bottom:20px; background-color: var(--background-primary); border-radius: 10px; width: fit-content;"></div>
|
||||
</div>
|
||||
{%endif%}
|
||||
|
||||
{%if dgShowBacklinks === true %}
|
||||
{%if settings.dgShowBacklinks === true %}
|
||||
<h3>Links to this page</h3>
|
||||
{%- if backlinks.length === 0 -%}
|
||||
<div class="backlink-card">
|
||||
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{%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 %}
|
||||
|
||||
|
@ -12,15 +12,16 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
|
||||
{%include "components/notegrowthhistory.njk"%}
|
||||
|
||||
<div class="content">
|
||||
{% if dgHomeLink !== false%}
|
||||
{% if settings.dgHomeLink !== false%}
|
||||
<a href="/">🏡 Back Home</a>
|
||||
{% 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>
|
||||
{% endif %}
|
||||
{{ content | link | highlight | safe}}
|
||||
|
||||
{% if dgShowBacklinks === true or dgShowLocalGraph === true%}
|
||||
{% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true%}
|
||||
{%include "components/sidebar.njk"%}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -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 "";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{ collections.gardenEntry[0].fileSlug }}</title>
|
||||
<title>{{ noteTitle }}</title>
|
||||
{%include "components/pageheader.njk"%}
|
||||
</head>
|
||||
<body class="theme-{{meta.baseTheme}} markdown-preview-view markdown-rendered">
|
||||
{%include "components/notegrowthhistory.njk"%}
|
||||
<div class="content">
|
||||
|
||||
{% if collections.gardenEntry[0].data.dgShowInlineTitle === true %}
|
||||
<h1>{{ collections.gardenEntry[0].fileSlug }}</h1>
|
||||
{% if settings.dgShowInlineTitle === true %}
|
||||
<h1>{{ noteTitle }}</h1>
|
||||
{% 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%}
|
||||
</div>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user