mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-04 12:00:02 +00:00
🌅 Initial commit
This commit is contained in:
commit
5c88fc3f67
54
.eleventy.js
Normal file
54
.eleventy.js
Normal file
@ -0,0 +1,54 @@
|
||||
const eleventyPluginSyntaxHighlighter = require('@11ty/eleventy-plugin-syntaxhighlight');
|
||||
const markdownItMermaid = require('markdown-it-mermaid');
|
||||
|
||||
module.exports = function(eleventyConfig) {
|
||||
|
||||
let markdownIt = require("markdown-it");
|
||||
let markdownLib = markdownIt({
|
||||
html: true,
|
||||
}).use(function(md) {
|
||||
//https://github.com/DCsunset/markdown-it-mermaid-plugin
|
||||
const origRule = md.renderer.rules.fence.bind(md.renderer.rules);
|
||||
md.renderer.rules.fence = (tokens, idx, options, env, slf) => {
|
||||
const token = tokens[idx];
|
||||
if (token.info === 'mermaid') {
|
||||
const code = token.content.trim();
|
||||
return `<pre class="mermaid">${code}</pre>`;
|
||||
}
|
||||
|
||||
// Other languages
|
||||
return origRule(tokens, idx, options, env, slf);
|
||||
};
|
||||
});
|
||||
|
||||
eleventyConfig.setLibrary("md", markdownLib);
|
||||
|
||||
|
||||
eleventyConfig.addFilter('link', function(str) {
|
||||
return str && str.replace(/\[\[(.*?)\]\]/g, '<a href="/notes/$1">$1</a>');
|
||||
})
|
||||
|
||||
eleventyConfig.addPlugin(eleventyPluginSyntaxHighlighter, {
|
||||
init: function({ Prism }) {
|
||||
Prism.languages['ad-note'] = Prism.languages.extend("markup", {});
|
||||
Prism.languages['ad-tip'] = Prism.languages.extend("markup", {});
|
||||
Prism.languages['ad-warning'] = Prism.languages.extend("markup", {});
|
||||
Prism.languages['ad-caution'] = Prism.languages.extend("markup", {});
|
||||
Prism.languages['ad-important'] = Prism.languages.extend("markup", {});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
dir: {
|
||||
input: "src/site",
|
||||
output: "dist",
|
||||
data: `_data`
|
||||
},
|
||||
templateFormats: ["njk", "md", "11ty.js", "css"],
|
||||
htmlTemplateEngine: "njk",
|
||||
markdownTemplateEngine: "njk",
|
||||
passthroughFileCopy: true,
|
||||
};
|
||||
|
||||
};
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
dist
|
||||
**/.env*
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Digital Obsidian Garden
|
||||
This is the template to be used together with the [Garden Obsidian Plugin]().
|
||||
See the README in the plugin repo for information on how to set it up.
|
||||
[](https://app.netlify.com/start/deploy?repository=https://github.com/oleeskild/digitalgarden)
|
7
netlify.toml
Normal file
7
netlify.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[build]
|
||||
publish = "dist"
|
||||
|
||||
[[redirects]]
|
||||
from = "/*"
|
||||
to = "/404"
|
||||
status = 404
|
8041
package-lock.json
generated
Normal file
8041
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "web",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "npm run dev",
|
||||
"dev": "cross-env ELEVENTY_ENV=dev eleventy --serve",
|
||||
"build": "cross-env ELEVENTY_ENV=prod eleventy"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@11ty/eleventy": "^1.0.0",
|
||||
"cross-env": "^7.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-plugin-syntaxhighlight": "^4.0.0",
|
||||
"@azure/storage-blob": "^12.8.0",
|
||||
"@octokit/core": "^3.5.1",
|
||||
"dotenv": "^10.0.0",
|
||||
"markdown-it": "^12.3.2"
|
||||
}
|
||||
}
|
21
src/site/404.njk
Normal file
21
src/site/404.njk
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Nothing here</title>
|
||||
<link href="/styles/style.css" rel="stylesheet">
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="content centered">
|
||||
<div class="font-bg"> 😎 </div>
|
||||
<h1>There is nothing here</h1>
|
||||
<p>If you got here from a link, this note is probably not made public</p>
|
||||
<a href="/">Go back to garden entry</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
66
src/site/_data/versionednotes.js
Normal file
66
src/site/_data/versionednotes.js
Normal file
@ -0,0 +1,66 @@
|
||||
require('dotenv').config();
|
||||
const { Octokit } = require("@octokit/core");
|
||||
const githubToken = process.env.GH_TOKEN;
|
||||
const octokit = new Octokit({ auth: githubToken });
|
||||
const markdownIt = require("markdown-it");
|
||||
const md = markdownIt({
|
||||
html: true,
|
||||
}).use(function(md) {
|
||||
//https://github.com/DCsunset/markdown-it-mermaid-plugin
|
||||
const origRule = md.renderer.rules.fence.bind(md.renderer.rules);
|
||||
md.renderer.rules.fence = (tokens, idx, options, env, slf) => {
|
||||
const token = tokens[idx];
|
||||
if (token.info === 'mermaid') {
|
||||
const code = token.content.trim();
|
||||
return `<pre class="mermaid">${code}</pre>`;
|
||||
}
|
||||
|
||||
// Other languages
|
||||
return origRule(tokens, idx, options, env, slf);
|
||||
};
|
||||
});
|
||||
|
||||
module.exports = async function() {
|
||||
if (!process.env.ENABLE_VERSION_HISTORY) {
|
||||
return [];
|
||||
}
|
||||
//list all files
|
||||
const noteFolder = 'src/site/notes';
|
||||
const fs = require('fs');
|
||||
|
||||
const files = fs.readdirSync(noteFolder).filter(file => file.endsWith(".md")).map(file => noteFolder + '/' + file);
|
||||
const notes = [];
|
||||
for (const filePath of files) {
|
||||
const fileCommits = await octokit.request(`GET /repos/{owner}/{repo}/commits?path=${encodeURI(filePath)}`, {
|
||||
owner: process.env.GH_USERNAME,
|
||||
repo: process.env.GH_REPO_NAME
|
||||
})
|
||||
if (filePath.indexOf("digital garden") > -1) {
|
||||
console.log(fileCommits);
|
||||
}
|
||||
for (const commit of fileCommits.data) {
|
||||
|
||||
const sha = commit.sha
|
||||
const fileData = await octokit.request(`GET /repos/{owner}/{repo}/contents/${encodeURI(filePath)}?ref=${sha}`, {
|
||||
owner: process.env.GH_USERNAME,
|
||||
repo: process.env.GH_REPO_NAME
|
||||
});
|
||||
const content = Buffer.from(fileData.data.content, 'base64').toString('utf8');
|
||||
const segments = filePath.split("/");
|
||||
const name = segments[segments.length - 1].replace(".md", "");
|
||||
const date = commit.commit.author.date;
|
||||
let markdown = ''
|
||||
try {
|
||||
markdown = md.render(content);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
const note = { content: markdown, title: name, fullTitle: name + " - " + sha, sha: sha, date: date };
|
||||
|
||||
notes.push(note);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return notes;
|
||||
}
|
16
src/site/_includes/components/notegrowthhistory.njk
Normal file
16
src/site/_includes/components/notegrowthhistory.njk
Normal file
@ -0,0 +1,16 @@
|
||||
{%- if collections.versionednote.length > 0 -%}
|
||||
<div style="position:absolute; top:100px; right:0; padding:20px 15px 40px 15px; background-color:#2a2a2a; border-radius: 25px;">
|
||||
<!-- animate big when moving over -->
|
||||
<h2>Notegrowth</h2>
|
||||
<ul style="list-style-type: none; padding:0;">
|
||||
{%- for note in collections.versionednote -%}
|
||||
{%- if note.data.item.title === page.fileSlug -%}
|
||||
<li style="padding:10px">
|
||||
<a href="{{ note.url }}">
|
||||
{{note.data.item.date}}</a>
|
||||
</li>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
</div>
|
||||
{%-endif-%}
|
16
src/site/_includes/components/pageheader.njk
Normal file
16
src/site/_includes/components/pageheader.njk
Normal file
@ -0,0 +1,16 @@
|
||||
<script src="https://unpkg.com/mermaid/dist/mermaid.min.js"></script>
|
||||
<script>
|
||||
mermaid.initialize({startOnLoad: true});
|
||||
</script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js" integrity="sha512-hpZ5pDCF2bRCweL5WoA0/N1elet1KYL5mx3LP555Eg/0ZguaHawxNvEjF6O3rufAChs16HVNhEc6blF/rZoowQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-sv0slik/5O0JIPdLBCR2A3XDg/1U3WuDEheZfI/DI5n8Yqc3h5kjrnr46FGBNiUAJF7rE4LHKwQ/SoSLRKAxEA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism-okaidia.min.css" integrity="sha512-mIs9kKbaw6JZFfSuo+MovjU+Ntggfoj8RwAmJbVXQ5mkAX5LlgETQEweFPI18humSPHymTb5iikEOKWF7I8ncQ==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
|
||||
|
||||
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
||||
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
|
||||
<link href="/styles/style.css" rel="stylesheet">
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
|
17
src/site/_includes/layouts/note.njk
Normal file
17
src/site/_includes/layouts/note.njk
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{ page.fileSlug }}</title>
|
||||
{%include "components/pageheader.njk"%}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{%include "components/notegrowthhistory.njk"%}
|
||||
|
||||
<div class="content">
|
||||
<a href="/">← Back to garden entry</a>
|
||||
{{ content | link | safe}}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
15
src/site/_includes/layouts/versionednote.njk
Normal file
15
src/site/_includes/layouts/versionednote.njk
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{ item.title }}</title>
|
||||
{%include "components/pageheader.njk"%}
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
{%- if item.tags !== 'Garden' -%}
|
||||
<a href="/">← Back to Garden Entry</a>
|
||||
{%endif%}
|
||||
{{ item.content | link | safe}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
15
src/site/index.njk
Normal file
15
src/site/index.njk
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
{%include "components/pageheader.njk"%}
|
||||
</head>
|
||||
<body>
|
||||
{%include "components/notegrowthhistory.njk"%}
|
||||
<div class="content">
|
||||
{%- for garden in collections.gardenEntry -%}
|
||||
{{garden.templateContent | link | safe }}
|
||||
{%- endfor -%}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
5
src/site/notes/notes.json
Normal file
5
src/site/notes/notes.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"layout" : "layouts/note.njk",
|
||||
"tags" : "note",
|
||||
"templateEngineOverride": "njk,md"
|
||||
}
|
142
src/site/styles/style.css
Normal file
142
src/site/styles/style.css
Normal file
@ -0,0 +1,142 @@
|
||||
.content {
|
||||
max-width: 900px;
|
||||
margin: auto;
|
||||
font-size: 22px;
|
||||
line-height: 1.5;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content h1 {
|
||||
color: #FFEF60;
|
||||
}
|
||||
|
||||
.content h2 {
|
||||
color: #F06449;
|
||||
}
|
||||
|
||||
.content h3 {
|
||||
color: #D4FCC3;
|
||||
}
|
||||
|
||||
.content h4 {
|
||||
color: #72DCFF;
|
||||
}
|
||||
|
||||
.mermaid svg {
|
||||
background: white;
|
||||
border-radius: 25px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.centered {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: rgb(32, 31, 31);
|
||||
color: white;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
padding-bottom: 3px;
|
||||
border-bottom: 1px solid rgb(97, 186, 245);
|
||||
color: rgb(97, 186, 245);
|
||||
}
|
||||
|
||||
.font-bg {
|
||||
font-size: 92px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
background: #ffffff17;
|
||||
border-left: 10px solid #C1DBE3;
|
||||
margin: 1.5em 10px;
|
||||
padding: 0.5em 10px;
|
||||
quotes: "\201C""\201D""\2018""\2019";
|
||||
}
|
||||
|
||||
blockquote:before {
|
||||
color: #ccc;
|
||||
content: open-quote;
|
||||
font-size: 4em;
|
||||
line-height: 0.1em;
|
||||
margin-right: 0.1em;
|
||||
vertical-align: -0.4em;
|
||||
}
|
||||
|
||||
blockquote p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
pre[class*="language-ad-"]::before {
|
||||
display: block;
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
code[class*="language-ad-"] {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
pre[class*="language-ad-"] {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
word-wrap: break-word;
|
||||
background-color: #3b2e58;
|
||||
border: 1px solid #3b2e58;
|
||||
border-radius: 6px;
|
||||
color: rgb(230, 230, 230);
|
||||
display: block;
|
||||
font-size: 1rem;
|
||||
margin-top: 1rem;
|
||||
outline-color: rgb(230, 230, 230);
|
||||
padding: 1rem;
|
||||
position: relative;
|
||||
transition: height .5s ease-in, opacity .5s ease-in;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
pre.language-ad-note::before {
|
||||
content: "🖊️ Note";
|
||||
}
|
||||
|
||||
pre.language-ad-tip::before {
|
||||
content: "💡 Tip";
|
||||
}
|
||||
|
||||
pre.language-ad-warning::before {
|
||||
content: "⚠️ Warning";
|
||||
}
|
||||
|
||||
pre.language-ad-important::before {
|
||||
content: "❗️ Important";
|
||||
}
|
||||
|
||||
pre.language-ad-caution::before {
|
||||
content: "⚠️ Caution";
|
||||
}
|
||||
|
||||
pre.language-ad-tip {
|
||||
background-color: rgb(5, 75, 22);
|
||||
border-color: rgb(5, 75, 22);
|
||||
}
|
||||
|
||||
pre.language-ad-warning {
|
||||
background-color: rgb(106, 75, 22);
|
||||
border-color: rgb(106, 75, 22);
|
||||
}
|
||||
|
||||
pre.language-ad-important {
|
||||
background-color: rgb(0, 65, 115);
|
||||
border-color: rgb(0, 65, 115);
|
||||
}
|
||||
|
||||
pre.language-ad-caution {
|
||||
background-color: rgb(99, 0, 1);
|
||||
border-color: rgb(99, 0, 1);
|
||||
}
|
10
src/site/versionednote.njk
Normal file
10
src/site/versionednote.njk
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
layout: layouts/versionednote.njk
|
||||
tags: versionednote
|
||||
pagination:
|
||||
data: versionednotes
|
||||
size: 1
|
||||
alias: item
|
||||
addAllPagesToCollections: true
|
||||
permalink: versionednotes/{{item.title}}/{{item.sha}}/index.html
|
||||
---
|
Loading…
x
Reference in New Issue
Block a user