File tree 3 files changed +110
-1
lines changed
3 files changed +110
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : CI
2
+ on :
3
+ push :
4
+ branches :
5
+ - master
6
+ pull_request :
7
+
8
+ env :
9
+ # renovate: datasource=github-tags depName=rust lookupName=rust-lang/rust
10
+ RUST_VERSION : 1.86.0
11
+
12
+ jobs :
13
+ lint :
14
+ runs-on : ubuntu-latest
15
+ steps :
16
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
17
+
18
+ - run : rustup override set ${{ env.RUST_VERSION }}
19
+ - run : rustup component add clippy
20
+ - run : rustup component add rustfmt
21
+ - uses : Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
22
+
23
+ - run : cargo clippy --workspace -- -D warnings
24
+ - run : cargo fmt --check --all
25
+ - run : cargo test --package front_matter
26
+
27
+ build :
28
+ runs-on : ubuntu-latest
29
+ steps :
30
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
31
+
32
+ - run : rustup override set ${{ env.RUST_VERSION }}
33
+ - uses : Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
34
+
35
+ - name : Install Zola
36
+ run : cargo install --locked --git https://github.com/senekor/zola --rev 620bf3c46a39b41db30b1e91756a995bbff84d3a
37
+ - run : zola build
38
+ - run : cp CNAME ./public/
39
+ - run : touch public/.nojekyll
40
+
41
+ - uses : actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
42
+ with :
43
+ path : public
44
+
45
+ deploy :
46
+ if : ${{ github.ref == 'refs/heads/master' }}
47
+
48
+ needs : build
49
+
50
+ permissions :
51
+ pages : write
52
+ id-token : write
53
+
54
+ runs-on : ubuntu-latest
55
+ steps :
56
+ - id : deployment
57
+ uses : actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
58
+
59
+ environment :
60
+ name : github-pages
61
+ url : ${{ steps.deployment.outputs.page_url }}
Original file line number Diff line number Diff line change @@ -33,10 +33,15 @@ You can store your main blog post in `content/<some-slug>/index.md`.
33
33
Images go into the same directory: ` content/<some-slug>/my_image.png ` .
34
34
Now you can reference that image with a simple relative path: `  ` .
35
35
36
+ A post's date of publication is embedded in the ` path ` key of the front matter.
37
+ Keep the placeholder (` 9999/12/99 ` ) until the post is about to be merged.
38
+ You can easily do so by adding a comment containing the string ` publish=today ` on the PR.
39
+ Don't worry, there's a merge queue check to make sure you don't forget.
40
+
36
41
Here is an example of the front matter format:
37
42
``` md
38
43
+++
39
- path = "2015/03/15 /some-slug"
44
+ path = "9999/12/99 /some-slug"
40
45
title = "Title of the blog post"
41
46
authors = ["Blog post author (or on behalf of which team)"]
42
47
description = "(optional)"
Original file line number Diff line number Diff line change @@ -212,4 +212,47 @@ The post {post} has abnormal front matter.
212
212
} ;
213
213
}
214
214
}
215
+
216
+ /// This test is run by the merge queue check to make sure a blog post
217
+ /// isn't merged before its date is set. The date of a blog post is usually
218
+ /// a placeholder (path = "9999/12/99/...") until shortly before it's
219
+ /// published. Setting the date can be done manually or by commenting
220
+ /// "publish=today" on the PR.
221
+ #[ test]
222
+ #[ ignore]
223
+ fn date_is_set ( ) {
224
+ let repo_root = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( ".." ) ;
225
+
226
+ let posts = fs:: read_dir ( repo_root. join ( "content" ) )
227
+ . unwrap ( )
228
+ . chain ( fs:: read_dir ( repo_root. join ( "content/inside-rust" ) ) . unwrap ( ) )
229
+ . map ( |p| p. unwrap ( ) . path ( ) )
230
+ . filter ( |p| p. is_file ( ) && p. file_name ( ) != Some ( "_index.md" . as_ref ( ) ) ) ;
231
+
232
+ for post in posts {
233
+ let slug = post. file_stem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
234
+
235
+ let content = fs:: read_to_string ( & post) . unwrap ( ) ;
236
+ let ( front_matter, _) = parse ( & content) . unwrap ( ) ;
237
+
238
+ if front_matter. path . starts_with ( "9999/12/99/" ) {
239
+ panic ! (
240
+ "
241
+ The post {slug} has a placeholder publication date.
242
+
243
+ ┌──────────────────────────────────────────────────────────────────────────┐
244
+ │ │
245
+ │ You can set the publication date automatically by commenting │
246
+ │ │
247
+ │ publish=today │
248
+ │ │
249
+ │ on the pull request of the post. │
250
+ │ (You can also edit the 'path' key in the front matter directly.) │
251
+ │ │
252
+ └──────────────────────────────────────────────────────────────────────────┘
253
+ " ,
254
+ ) ;
255
+ }
256
+ }
257
+ }
215
258
}
You can’t perform that action at this time.
0 commit comments