Repository navigation
Expand file tree
/
Copy pathzerops.yml
More file actions
59 lines (58 loc) 路 2.79 KB
/
Copy pathzerops.yml
File metadata and controls
59 lines (58 loc) 路 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
zerops:
- setup: docs
build:
os: ubuntu
base: nodejs@20
envVariables:
URL: https://docs.zerops.io
MEILISEARCH_HOST: https://docs-search.zerops.io
MEILISEARCH_API_KEY: bfbc1c6fd31c47d525ce15f40af701d22b16a679baa99810c1a67a1f1d784731
MEILISEARCH_INDEX_UID: docs
buildCommands:
- yarn
- yarn prebuild
- yarn build
deployFiles:
- apps/docs/build/~
cache:
- ./node_modules/
- ./apps/docs/node_modules/
run:
base: static
initCommands:
- sudo sed -i 's/^\(\s*text\/plain\s\+\)txt;$/\1txt md;/' /etc/nginx/mime.types
- printf 'charset utf-8;\ncharset_types text/plain;\n' | sudo tee /etc/nginx/conf.d/charset.conf
# Advertise the markdown twin of every docs page as an RFC 8288 Link
# header, so agents that fetch over plain HTTP (or HEAD) discover it
# without parsing the HTML <head>. Mirrors the <link rel="alternate">
# emitted by src/theme/DocItem/Layout. The regex only matches
# extensionless paths, so assets and the .md files themselves are
# skipped; an empty value makes nginx omit the header entirely.
- printf 'map $request_uri $zerops_md_alternate {\n default "";\n /discord "";\n "~^(/[^.?#]*[^./?#])$" "<$1.md>; rel=alternate; type=text/markdown";\n}\nadd_header Link $zerops_md_alternate always;\n' | sudo tee /etc/nginx/conf.d/md-alternate.conf
# The static base falls back to /index.html for anything unmatched,
# which makes a bogus /foo.md answer 200 with the 260kB HTML shell --
# agents read that as a successful fetch. Narrow the .md location to a
# real 404. Self-reverting: if the config does not look the way we
# expect, the substitution simply no-ops, and a failed `nginx -t`
# restores the original file.
- |
F=$(sudo grep -rl 'location[^{]*\.md' /etc/nginx/ 2>/dev/null | head -1)
if [ -n "$F" ]; then
sudo cp "$F" /tmp/nginx-md.bak
sudo perl -0777 -i -pe 's!(location[^{\n]*\.md[^{\n]*\{[^{}]*?)try_files[^;]*;!$1try_files \$uri =404;!' "$F"
sudo nginx -t || sudo cp /tmp/nginx-md.bak "$F"
fi
true
- sudo service nginx reload
routing:
headers:
- for: "~* \\.md$*"
values:
Content-Disposition: '"inline" always'
X-Content-Type-Options: '"nosniff"'
X-Robots-Tag: '"googlebot: noindex, nofollow, bingbot: noindex, nofollow"'
Cache-Control: '"public, max-age=3600, must-revalidate"'
- for: "~* ^/.*/img/.**"
values:
X-Robots-Tag: '"googlebot: noindex, nofollow, bingbot: noindex, nofollow"'
Cache-Control: '"public, max-age=86400, immutable"'