forked from shadowfacts/shadowfacts.net
Add CSS cache buster
This commit is contained in:
parent
bd8d958bae
commit
9c0e7e8c68
|
@ -3,12 +3,16 @@ import * as metadata from "./metadata";
|
|||
import { Metadata } from "./metadata";
|
||||
import * as util from "./util";
|
||||
|
||||
// create the date once so that every page uses the same value
|
||||
const stylesheetCacheBuster = new Date().getTime();
|
||||
|
||||
export default async function layout(text: string, pageMetadata: Metadata, layoutPath: string): Promise<string> {
|
||||
const layoutFile = path.join("site/layouts", layoutPath);
|
||||
let layoutPage = await metadata.get(layoutFile);
|
||||
text = util.render(layoutPage.text, {
|
||||
content: text,
|
||||
metadata: pageMetadata
|
||||
metadata: pageMetadata,
|
||||
stylesheetCacheBuster,
|
||||
}, layoutFile);
|
||||
if (layoutPage.metadata.layout) {
|
||||
return await layout(text, pageMetadata, layoutPage.metadata.layout);
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
<script>
|
||||
(() => {
|
||||
const theme = localStorage.getItem("theme") || "auto";
|
||||
document.write(`<link rel="stylesheet" href="/css/${theme}.css">`);
|
||||
document.write(`<link rel="stylesheet" href="/css/${theme}.css?<%= stylesheetCacheBuster %>">`);
|
||||
})();
|
||||
</script>
|
||||
<noscript>
|
||||
<link rel="stylesheet" href="/css/auto.css">
|
||||
<link rel="stylesheet" href="/css/auto.css?<%= stylesheetCacheBuster %>">
|
||||
</noscript>
|
||||
</head>
|
||||
<body itemscope itemtype="https://schema.org/Blog">
|
||||
|
|
Loading…
Reference in New Issue