-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
195 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,26 @@ | ||
require("dotenv").config(); | ||
const axios = require("axios"); | ||
const fs = require("fs"); | ||
const crypto = require("crypto"); | ||
const glob = require("glob"); | ||
|
||
module.exports = async () => { | ||
let baseUrl = process.env.SITE_BASE_URL || ""; | ||
if (baseUrl && !baseUrl.startsWith("http")) { | ||
baseUrl = "https://" + baseUrl; | ||
} | ||
let themeStyle = glob.sync("src/site/styles/theme.*.css")[0] || ""; | ||
if (themeStyle) { | ||
themeStyle = themeStyle.split("site")[1]; | ||
} | ||
const meta = { | ||
env: process.env.ELEVENTY_ENV, | ||
theme: process.env.THEME, | ||
themeStyle, | ||
baseTheme: process.env.BASE_THEME || "dark", | ||
siteName: process.env.SITE_NAME_HEADER || "Digital Garden", | ||
siteBaseUrl: baseUrl, | ||
}; | ||
|
||
module.exports = async() => { | ||
let themeStyle = ""; | ||
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>`; | ||
} | ||
let baseUrl = process.env.SITE_BASE_URL || ""; | ||
if(baseUrl && !baseUrl.startsWith("http")){ | ||
baseUrl = "https://" + baseUrl; | ||
} | ||
const meta ={ | ||
env: process.env.ELEVENTY_ENV, | ||
theme: process.env.THEME, | ||
themeStyle: themeStyle, | ||
baseTheme: process.env.BASE_THEME || "dark", | ||
siteName: process.env.SITE_NAME_HEADER || "Digital Garden", | ||
siteBaseUrl: baseUrl, | ||
}; | ||
|
||
return meta; | ||
return meta; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.