mirror of
https://github.com/rust-lang/mdBook.git
synced 2025-12-27 10:16:09 -05:00
feat(html): cache bust static files by adding hashes to file names
Closes rust-lang#1254
This commit is contained in:
@@ -13,6 +13,7 @@ mathjax-support = true
|
||||
site-url = "/mdBook/"
|
||||
git-repository-url = "https://github.com/rust-lang/mdBook/tree/master/guide"
|
||||
edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
|
||||
hash-files = true
|
||||
|
||||
[output.html.playground]
|
||||
editable = true
|
||||
|
||||
@@ -168,6 +168,11 @@ The following configuration options are available:
|
||||
This string will be written to a file named CNAME in the root of your site, as
|
||||
required by GitHub Pages (see [*Managing a custom domain for your GitHub Pages
|
||||
site*][custom domain]).
|
||||
- **hash-files:** Include a cryptographic "fingerprint" of the files' contents in CSS, JavaScript, and image asset filenames,
|
||||
so that if the contents of the file are changed, the name of the file will also change.
|
||||
For example, `css/chrome.css` may become `css/chrome-9b8f428e.css`.
|
||||
HTML files are not renamed.
|
||||
Static CSS and JS files can reference each other using `{{ resource "filename" }}` directives.
|
||||
|
||||
[custom domain]: https://docs.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site
|
||||
|
||||
|
||||
@@ -99,3 +99,13 @@ Of course the inner html can be changed to your liking.
|
||||
|
||||
*If you would like other properties or helpers exposed, please [create a new
|
||||
issue](https://github.com/rust-lang/mdBook/issues)*
|
||||
|
||||
### 3. resource
|
||||
|
||||
The path to a static file.
|
||||
It implicitly includes `path_to_root`,
|
||||
and accounts for files that are renamed with a hash in their filename.
|
||||
|
||||
```handlebars
|
||||
<link rel="stylesheet" href="{{ resource "css/chrome.css" }}">
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user