forked from leftypol/leftypol
main.js: load styles with dyanamically provided resource version.
This is done because: - If the version is updated before the rebuild, someone might cache the old version in the meanwhile. - One could not rebuild javascript before updating the version. Now it's possible.
This commit is contained in:
parent
92e2344926
commit
fe598cf3a4
1 changed files with 9 additions and 1 deletions
|
@ -156,7 +156,14 @@ function changeStyle(styleName, link) {
|
|||
this.media = 'all';
|
||||
mainStylesheetElement.media = 'none';
|
||||
}
|
||||
document.getElementById('stylesheet').href = styles[styleName];
|
||||
|
||||
let style = styles[styleName];
|
||||
if (style !== '') {
|
||||
// Add the version of the resource if the style is not the embedded one.
|
||||
style = style + '?v=' + resourceVersion;
|
||||
}
|
||||
|
||||
document.getElementById('stylesheet').href = style;
|
||||
selectedstyle = styleName;
|
||||
|
||||
if (codestyles[styleName]) {
|
||||
|
@ -571,6 +578,7 @@ function ready() {
|
|||
|
||||
var post_date = "{{ config.post_date }}";
|
||||
var max_images = {{ config.max_images }};
|
||||
var resourceVersion = document.currentScript.getAttribute('data-resource-version');
|
||||
|
||||
onReady(init);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue