rendered HTML minification

This commit is contained in:
grey-cat-1908 2024-09-06 14:52:16 +03:00
parent 6dc4b53ce0
commit 08e597ccd9
6 changed files with 133 additions and 67 deletions

View file

@ -24,6 +24,12 @@ I didn't want to create a 404 page. I wanted to keep things simple so that all p
**CLOUDFLARE CREATE A DEFAULT 404 PAGE PLEASE** **CLOUDFLARE CREATE A DEFAULT 404 PAGE PLEASE**
## About HTML minification
The build script has some issues with indentation and code beautification. I'm too lazy to fix them, so I decided to minify the rendered HTML instead.
I'm using [this excellent tool](https://github.com/wilsonzlin/minify-html) to minify rendered HTML.
## A little historical note ## A little historical note
Previously, I didn't want to simplify the site that much, and there are a lot more pages and material here. You can see the old version [here](https://41ecb9be.arbuzicu.pages.dev/). Previously, I didn't want to simplify the site that much, and there are a lot more pages and material here. You can see the old version [here](https://41ecb9be.arbuzicu.pages.dev/).

View file

@ -1 +1,41 @@
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta property="og:site_name" content="Arbuz?">{{%META%}}<link rel="stylesheet" href="/custom.css"><link rel="stylesheet" href="/favicon.ico"><link rel="icon" href="https://avatars.githubusercontent.com/u/61203964"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script><script>hljs.highlightAll()</script><title>{{%TITLE%}}</title></head><body><nav><b>mrkrk</b><a href="/">Home</a><a href="/projects">Projects</a></nav><main class="mc">{{%CONTENT%}}</main><script>MathJax={tex:{inlineMath:[["$","$"],["\\(","\\)"]]},svg:{fontCache:"global"}}</script><script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script></body></html> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta property="og:site_name" content="Arbuz?">
{{%META%}}
<link rel="stylesheet" href="/custom.css">
<link rel="stylesheet" href="/favicon.ico">
<link rel="icon" href="https://avatars.githubusercontent.com/u/61203964">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>
<script>
hljs.highlightAll()
</script>
<title>{{%TITLE%}}</title>
</head>
<body>
<nav>
<b>mrkrk</b>
<a href="/">Home</a>
<a href="/projects">Projects</a>
</nav>
<main class="mc">{{%CONTENT%}}</main>
<script>
MathJax = {
tex: {
inlineMath: [
["$", "$"],
["\\(", "\\)"]
]
},
svg: {
fontCache: "global"
}
}
</script>
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
</body>
</html>

View file

@ -1,7 +1,9 @@
import os import os
import shutil import shutil
import json import json
import mistune import mistune
import minify_html
markdown_renderer = mistune.create_markdown( markdown_renderer = mistune.create_markdown(
plugins=[ plugins=[
@ -61,10 +63,12 @@ def generate_html_content(directory, filename, is_blog=False):
template_to_use = blog_template_text if is_blog else template_text template_to_use = blog_template_text if is_blog else template_text
return ( return minify_html.minify(
template_to_use.replace("{{%CONTENT%}}", markdown_renderer(md_text)) template_to_use.replace("{{%CONTENT%}}", markdown_renderer(md_text))
.replace("{{%TITLE%}}", meta.get("title", "")) .replace("{{%TITLE%}}", meta.get("title", ""))
.replace("{{%META%}}", meta_data) .replace("{{%META%}}", meta_data),
minify_js=True,
remove_processing_instructions=True,
) )

View file

@ -1 +1,2 @@
mistune mistune
minify-html

View file

@ -1,5 +1,5 @@
:root { :root {
--font: 'Onest', sans-serif; --font: "Onest", sans-serif;
--bg-color: #15171f; --bg-color: #15171f;
--font-color: #dadada; --font-color: #dadada;
--nav-font-color: white; --nav-font-color: white;
@ -18,7 +18,6 @@
font-weight: normal; font-weight: normal;
} }
body { body {
margin: 1rem auto; margin: 1rem auto;
background-color: var(--bg-color); background-color: var(--bg-color);
@ -52,8 +51,11 @@ nav a {
text-decoration: none; text-decoration: none;
} }
/* РАЗМЕТКА */ .mc h1,
.mc h1, .mc h2, .mc h3, .mc h4, .mc h5 { .mc h2,
.mc h3,
.mc h4,
.mc h5 {
color: #fff; color: #fff;
text-align: left !important; text-align: left !important;
} }
@ -89,14 +91,9 @@ nav a {
margin-bottom: 15px; margin-bottom: 15px;
} }
.mc table * { .mc table td,
table th {
}
.mc table td, table th {
padding: 15px; padding: 15px;
border-bottom: 1px solid #d6d6d6; border-bottom: 1px solid #d6d6d6;
} }
img[alt=play_button_exp] { width: 120px; }

View file

@ -1 +1,19 @@
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">{{%META%}}<link rel="stylesheet" href="/custom.css"><link rel="icon" href="/favicon.ico"><title>{{%TITLE%}}</title></head><body><nav data-nosnippet><b>mrkrk</b><a href="/">Home</a><a href="/projects">Projects</a></nav><main class="mc">{{%CONTENT%}}</main></body></html> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
{{%META%}}
<link rel="stylesheet" href="/custom.css">
<link rel="icon" href="/favicon.ico">
<title>{{%TITLE%}}</title>
</head>
<body>
<nav data-nosnippet>
<b>mrkrk</b>
<a href="/">Home</a>
<a href="/projects">Projects</a>
</nav>
<main class="mc">{{%CONTENT%}}</main>
</body>
</html>