Handle themes not adhering to obsidian v1

This commit is contained in:
Ole Eskild Steensen 2022-11-27 15:16:44 +01:00
parent 6b1460d0c0
commit 9d2eed43d1

View File

@ -4,8 +4,22 @@ const axios = require("axios");
module.exports = async() => {
let themeStyle = "";
if (process.env.THEME) {
const res = await axios.get(process.env.THEME)
let themeUrl = process.env.THEME;
if (themeUrl) {
//https://forum.obsidian.md/t/1-0-theme-migration-guide/42537
//Not all themes with no legacy mark have a theme.css file, so we need to check for it
try{
await axios.get(themeUrl);
}catch{
if(themeUrl.indexOf("theme.css") > -1){
themeUrl = themeUrl.replace("theme.css", "obsidian.css");
}
else if(themeUrl.indexOf("obsidian.css") > -1){
themeUrl = themeUrl.replace("obsidian.css", "theme.css");
}
}
const res = await axios.get(themeUrl);
themeStyle = `<style>${res.data}</style>`;
}
const meta ={