Added support for setting obsidiantheme

This commit is contained in:
Ole Eskild Steensen 2022-03-15 15:11:50 +01:00
parent 845b58cf91
commit 4689824bab
6 changed files with 48 additions and 26 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
THEME=https://raw.githubusercontent.com/kepano/obsidian-minimal/master/Minimal.css
BASE_THEME=dark

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
node_modules
dist
**/.env*

41
package-lock.json generated
View File

@ -12,6 +12,7 @@
"@azure/storage-blob": "^12.8.0",
"@octokit/core": "^3.5.1",
"@sindresorhus/slugify": "^1.1.0",
"axios": "^0.26.1",
"dotenv": "^10.0.0",
"gray-matter": "^4.0.3",
"markdown-it": "^12.3.2",
@ -603,12 +604,11 @@
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dev": true,
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
"dependencies": {
"follow-redirects": "^1.14.0"
"follow-redirects": "^1.14.8"
}
},
"node_modules/babel-walk": {
@ -1583,7 +1583,6 @@
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
"dev": true,
"funding": [
{
"type": "individual",
@ -2467,6 +2466,15 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/localtunnel/node_modules/axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dev": true,
"dependencies": {
"follow-redirects": "^1.14.0"
}
},
"node_modules/localtunnel/node_modules/cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
@ -5329,12 +5337,11 @@
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dev": true,
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
"requires": {
"follow-redirects": "^1.14.0"
"follow-redirects": "^1.14.8"
}
},
"babel-walk": {
@ -6130,8 +6137,7 @@
"follow-redirects": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
"dev": true
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
},
"form-data": {
"version": "4.0.0",
@ -6775,6 +6781,15 @@
"color-convert": "^2.0.1"
}
},
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dev": true,
"requires": {
"follow-redirects": "^1.14.0"
}
},
"cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",

View File

@ -24,6 +24,7 @@
"@azure/storage-blob": "^12.8.0",
"@octokit/core": "^3.5.1",
"@sindresorhus/slugify": "^1.1.0",
"axios": "^0.26.1",
"dotenv": "^10.0.0",
"gray-matter": "^4.0.3",
"markdown-it": "^12.3.2",

View File

@ -1,13 +1,18 @@
require("dotenv").config();
let themeStyle = "";
if (process.env.THEME) {
fetch(process.env.THEME).then(response => response.text()).then(text => {
themeStyle = "<style>" + text + "</style>";
});
}
module.exports = {
env: process.env.ELEVENTY_ENV,
theme: process.env.THEME,
themeStyle: themeStyle,
baseTheme: process.env.BASE_THEME || "dark"
const axios = require("axios");
module.exports = async() => {
let themeStyle = "";
if (process.env.THEME) {
const res = await axios.get(process.env.THEME)
themeStyle = `<style>${res.data}</style>`;
}
return {
env: process.env.ELEVENTY_ENV,
theme: process.env.THEME,
themeStyle: themeStyle,
baseTheme: process.env.BASE_THEME || "dark"
}
};

View File

@ -21,7 +21,7 @@
<link href="/styles/style.css" rel="stylesheet">
{%-if meta.themeStyle%}
{{meta.themeStyle}}
{{meta.themeStyle | safe}}
{%endif%}
<link href="/styles/custom-style.css" rel="stylesheet">