pretty.html: fetch stylesheet only if the var is declared

otherwise the app will perform an unnecessary 404 request everytime a
theme is not declared

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain 2021-01-06 00:58:10 +05:30
parent 5277c60b81
commit 7cfe364b8c
2 changed files with 3 additions and 1 deletions

View File

@ -24,7 +24,7 @@ fn pretty_retrieve(id: PasteId) -> Option<Template> {
let mut contents = String::new();
file.read_to_string(&mut contents).unwrap();
let theme = env::var("THEME").unwrap_or(".".to_string());
let theme = env::var("THEME").unwrap_or("".to_string());
let mut map = HashMap::new();
map.insert("title", id.to_string());

View File

@ -69,7 +69,9 @@
</style>
<!-- Bring your own theme -->
{% if theme %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.5.0/build/styles/{{ theme }}.min.css">
{% endif %}
</head>