Deployment Uye Online
i18n.site
inotora dhizaini-peji rekuvaka, uye peji rekupinda webhusaiti uye zvemukati webhusaiti zvinoiswa zvakazvimirira.
Mushure mekuita shanduro iri pamusoro, madhairekitori htm
uye v
anozogadzirwa pasi md/out/dev
dhairekitori.
Pano, dev
inoreva kuti yakavakwa zvichibva pane .i18n/htm/dev.yml
yekumisikidza faira.
dev
directory :
Iyo htm
dhairekitori ndiyo peji rekupinda webhusaiti.
Iyo v
dhairekitori ine webhusaiti zvirimo nenhamba dzeshanduro.
Ongororo yemunharaunda haina basa nezve nhamba yeshanduro uye inokopa ese mafaera out/dev/v/0.1.0
dhairekitori.
Kuti ibudiswe zviri pamutemo, mafaera akachinjwa anokopwa kudhairekitori renhamba yeshanduro itsva.
Taura Faira Rekugadzirisa -c
Akasiyana ekugadzirisa mafaera achagadzira anowirirana madhairekitori mune out
dhairekitori.
Semuenzaniso, .i18n/htm/main.yml
ichagadzira iyo out/main
dhairekitori.
dev.yml
uye main.yml
ndiwo magadzirirwo akasarudzika.
dev
ndiyo chidimbu development
, ichiratidza nharaunda yebudiriro, inoshandiswa pakuona kwenzvimbo, uye zvakare ndiyo faira yekumisikidza.
ol
ndiyo chidimbu online
, ichiratidza nharaunda yepamhepo, iyo inoshandiswa kuburitswa zviri pamutemo Iri zvakare faira yekumisikidza kana uchishandisa command line paramita -n
kusvika npm
kuburitsa.
Iwe unogona zvakare kugadzira mamwe mafaera ekugadzirisa Shandisa --htm_conf
pamutsara wekuraira kutsanangura zita refaira rekushandisa.
semuyenzaniso:
i18n.site --htm_conf dist --save
Pano --save
inomiririra iyo yekuvandudza kuburitswa vhezheni nhamba.
Shambadzira zvirimo kunpmjs.com
Kutsikisa zvirimo ku npmjs.com
npm Login & Post
Isa nodejs
, pinda npm login
.
Rongedza md/.i18n/htm/main.yml
npmjs.com shandura kukosha md:
YOUR_NPM_PACKAGE
sezita rako repasuru npm
Zvadaro shandura md/.i18n/htm/main.package.json
Mhanya i18n.site --npm
kana i18n.site -n
mudhairekitori md
kuti ushandure nekushambadza.
Kana iwe ukashandisa inoenderera mberi yekubatanidza nharaunda kuti ibudise, hapana chikonzero chekuisa nodejs
Ingokopa iyo yakanyorwa-mukati uye yekuburitsa mvumo ~/.npmrc
kune zvakatipoteredza.
Kana ukagadzirisa zita repasuru v:
muna main.yml
, ndapota ita shuwa kudzima .i18n/v/main
kutanga wozoiburitsa.
Proxy Server Yakaburitswa Nenpm
Kana vashandisi vari mainland China vasangana nematambudziko etiweki uye vasingakwanise kuburitsa npm
mapakeji, vanogona kuseta nharaunda inosiyana https_proxy
kugadzirisa iyo proxy server.
Tichifunga kuti proxy server port yako ndeye 7890
, unogona kunyora:
https_proxy=http://127.0.0.1:7890 i18n.site -n
Kuzvibata Wega Zvemukati
Kana iwe uchida kuzvipa wega zvirimo, tanga wagadzirisa md/.i18n/htm/main.yml
uye shandura v: //unpkg.com/i18n.site
kune yako URL prefix, senge v: //i18n-v.xxx.com
.
Pinda iyo md
dhairekitori uye mhanya
i18n.site --htm_conf ol --save
kana chidimbu
i18n.site -c ol -s
Wobva wagadzirisa zvirimo md/out/main/v
dhairekitori kune iyo URL prefix nzira yakaiswa v:
.
Pakupedzisira, gadzirisa nguva ye cache yenzira inopera muna /.v
kusvika 1s
, kana zvisina kudaro zvinyorwa zvichangobva kubudiswa hazvigoni kuwanikwa pakarepo.
Iyo cache nguva yedzimwe nzira inogona kusetwa kune rimwe gore kana kupfuura kuderedza zvikumbiro zvisina basa.
Host Zvemukati Kune s3
Kuti uzvigadzirise CDN
, kuwedzera pakushandisa yako wega sevha, imwe yakajairika sarudzo ndeye kushandisa S3
+ .
Unogona kushandisa rclone kuti upinde musevha S3
, wobva watarisa uye gadzirisa script inotevera, uye ingoteedzera shanduko dzekuwedzera S3
pakuburitswa kwega kwega.
i18n.site -c ol -s
s3=your-s3
bucket=your-bucket
ver=$(head -1 .i18n/v/main/v.hash | cut -c 2-)
rclone copy --overwrite-dir out/main/htm/v/$ver $s3:/$bucket/$ver
rclone copy out/main/v/.v "$s3:/$bucket/"
Yeuka kugadzirisa CDN
kuitira kuti nguva ye cache yenzira inopera muna /.v
ndeye 1s
, kana zvisina kudaro zvinyorwa zvichangobva kusunungurwa hazvigone kuwanikwa pakarepo.
Buritsa Webhusaiti
Iyo webhusaiti inogona kuiswa chero kupi github page uye cloudflare page isarudzo dzakanaka.
Nekuti iyo webhusaiti inoshandisa architecture yepeji imwe-peji , yeuka kunyorazve URL nzira dzisina .
kusvika index.html
.
Webhusaiti yekupinda peji inongoda kuiswa kamwe chete, uye hapana chikonzero chekuisazve peji rekupinda webhusaiti kune zvinotevera zvinongedzo zvemukati.
Isa Pane github Peji
Chekutanga tinya github kuti ugadzire sangano i18n-demo
Wobva wagadzira imba yekuchengetera i18n-demo.github.io
pasi pesangano iri (ndokumbira tsiva i18n-demo
nezita resangano rawakagadzira):
Pakuburitsa zviri muchinyorwa chapfuura, out/main/htm
yagadzirwa :
ln -s index.html 404.html
Nekuti github page
haitsigire URL nzira yekunyorazve, 404.html
inoshandiswa pachinzvimbo.
Wobva wamhanya unotevera kuraira mune htm
dhairekitori (rangarira kutsiva i18n-demo/i18n-demo.github.io.git
nekero yako yekuchengetera) :
git init
git branch -M main
git remote add origin [email protected]:i18n-demo/i18n-demo.github.io.git
git push -u origin main -f
Mushure mekusundidzira kodhi, mirira kutumirwa github page
kuti imhanye zvinobudirira (sezvinoratidzwa pazasi) usati waiwana.
Kuti uwane demo peji ndapota ona:
https://i18n-demo.github.io
Isa Pane cloudflare Peji
cloudflare page github page
, inopa nzira yekunyorazve uye inoshamwaridzana nenyika yeChina uye inosvikika zvakanyanya.
Kuiswa cloudflare page
kazhinji kunobva pakuiswa github page
pamusoro.
Gadzira purojekiti uye sunga iyo i18n-demo.github.io
imba yekuchengetera pamusoro.
Iyo nzira inoratidzwa mumufananidzo uri pasi apa:
Ndapota tinya Add Account
kuti upe mukana kune sangano i18n-demo
.
Kana wakasunga dura rerimwe sangano, ungangoda kudzvanya Add Account
kaviri kuti upe mvumo kaviri sangano idzva risati raratidzwa.
Tevere, sarudza warehouse i18n-demo.github.io
, wobva wadzvanya Begin setup
, uye shandisa iyo default kukosha kune anotevera matanho.
Mushure mekusunga kekutanga, unofanirwa kumirira maminetsi mashoma usati waiwana.
Mushure mekutumirwa, unogona kusunga zita rezita renzvimbo.
Mushure mekusunga iyo yakasarudzika zita rezita, ndapota enda kuzita rezita kuti ugadzirise nzira yekunyorazve yepeji-peji application, sezvakaratidzwa pazasi:
Mitemo iri pamufananidzo uri pamusoro ndookuti tsiva i18n.site
mumutsetse wekutanga pazasi nezita renzvimbo yawakasunga.
(http.host in {"i18n.site"}) and not (
substring(http.request.uri.path,-3) in {".js" ".gz"} or
substring(http.request.uri.path,-4) in {".htm" ".rss" ".css" ".svg" ".ico" ".png" ".xml" ".txt"} or
substring(http.request.uri.path,-5) in {".html" ".avif" ".json"} or
ends_with(http.request.uri.path,".webmanifest")
)
Mukuwedzera, ndapota gadzirisa mitemo ye cache, sezvakaratidzwa pasi apa, uye isa nguva ye cache kumwedzi mumwe.
Ndokumbirawo shandura zita rezita rinoenderana mudanho rechipiri pamufananidzo uri pamusoro kune zita rezita rawakasunga.
Kugadzirisa Kutumirwa Kwewebhusaiti Mu Mainland China
Kana iwe uchida kuwana zvirinani kuwanikwa kwekuita munzvimbo yetiweki ye mainland China, ndapota nyoresa zita rezita kutanga.
Zvadaro, shandisa chinhu chekuchengetedza chevatengesi vemakore munyika + CDN
Tumira zvinotevera zvirimo out/main/htm
.
Unogona kushandisa komputa komputa kunyorazve nzira kuti ienderane kune imwechete-peji zvikumbiro Semuyenzaniso, Baidu Smart Cloud CDN
inogona kugadzirwa seizvi:
const uri = r.uri, p = uri.lastIndexOf(".");
if (
p < 0 ||
!"|js|css|htm|html|md|avif|json|ico|xml|rss|gz|mp4|png|svg|txt|webmanifest|".includes(
"|" + uri.slice(p + 1) + "|",
)
) {
const ua = r.headersIn["User-Agent"].toLowerCase()
if (/facebookexternalhit|slurp|bot|spider|curl/.test(ua)) {
r.return(
302,
(/baidu|yisou|sogou|360|byte/.test(ua) ? "/zh" : "/en") + r.uri + ".htm",
)
} else {
r.uri = "/index.html"
}
}
r.respHeader(() => {
const t = [], out = r.headersOut;
["Content-MD5", "Age", "Expires", "Last-Modified"].forEach(
i => delete out[i]
)
r.rawHeadersOut.forEach(i => {
const key = i[0].toLowerCase()
if (key.startsWith("x-") || key.startsWith("ohc-")) {
delete out[key]
}
})
out["Cache-Control"] = "max-age=" + 9e5
// Misoro yemhinduro inogona kusetwa kuti igadzirise kubuda, senge out.XXX = 'MSG';
})
Nekuti rekodhi MX
uye rekodha CNAME
haigone kugarisana, kana iwe uchida kugamuchira zita rezita maemail panguva imwe chete, iwe unofanirwa kushandira pamwe neiyo cname_flatten kusvika padanho CNAME
mune rekodhi A
.
Pamusoro pezvo, nekuti mhiri kwemakungwa kubhadhariswa kwevatengesi vemakore kuChina kwakadhura, kana iwe uchida kukwidziridza mitengo, unogona kushandisa Huawei DNS 's yemahara geographical resolution uye Cloudflare for SaaS 's tsika domain zita (sezvinoratidzwa pazasi) kuti uwane traffic diversion──Traffic routing munyika yeChina Baidu Cloud CDN
, traffic yepasi rose inoenda cloudflare .
Aya ma deployment optimization mhinduro akanyanya kuomarara uye achaunzwa muzvitsauko zvakasiyana mune ramangwana.
Generic Domain Name Redirection
Kana iwe ukashandisa i18n.site
kugadzira webhusaiti sewe webhusaiti yako huru, iwe kazhinji unoda kugadzirisa pan-domain redirection, kureva, redirect access to *.xxx.com
(kusanganisira www.xxx.com
) kusvika xxx.com
.
Ichi chinodiwa chinogona kuwanikwa nerubatsiro rweAlibaba Cloud CDN
EdgeScript
( gwaro reChirungu /
Wedzera zita renzvimbo muAlibaba CDN uye nongedzera zita renzvimbo *.xxx.com
kusvika CNAME
muAlibaba Cloud CDN
.
Semuenzaniso, iyo pan-domain zita redirection kumisikidzwa *.i18n.site
pamufananidzo uri pamusoro ndeyotevera:
rewrite(concat('https://i18n.site',$uri), 'redirect',301)
Shandisa Ne nginx
Ndokumbira uwedzere gadziriso yakafanana out/main/htm
/root/i18n/md/out/main/htm
server
ye nginx
location / {
root /root/i18n/md/out/main/htm;
add_header Cache-Control "max-age=9999999";
if ($uri !~* \.(avif|css|html|ico|js|json|png|svg|txt|webmanifest|xml)$) {
rewrite ^ /index.html last;
}
}
Kubva github action
Kuenderera Kubatanidzwa
Iwe unogona kutarisa kune zvinotevera kugadzirisa yako github action
:
name: i18n.site
on:
workflow_dispatch:
push:
branches:
- main
- dist
jobs:
i18n:
permissions:
repository-projects: write
contents: write
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: https://i18n.site
uses: i18n-site/github-action-i18n.site@main
with:
I18N_SITE_TOKEN: ${{ secrets.I18N_SITE_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Sezvinogona kuonekwa mukugadzirisa, kufambiswa kwebasa uku kunotangwa paunenge uchisundira kubazi main
uye bazi dist
.
Kufambiswa kwebasa kuchashandisa faira rekugadzirisa rinoenderana nezita rebazi kuti ribudise gwaro pano, .i18n/htm/main.yml
uye .i18n/htm/dist.yml
ichashandiswa sekugadzirisa kudhindwa.
Isu tinokurudzira anotevera akanakisa maitiro ekuburitsa gwaro maitiro:
Kana shanduko dzichisundirwa kubazi main
, gwaro rinokonzereswa kuti rivakwe uye riendeswe kuchiteshi chekutarisa (iyo chiteshi chekutarisa chiripo github page ).
Mushure mekusimbisa kuti gwaro racho rakarurama panzvimbo yekutarisa, kodhi yacho ichabatanidzwa uye yosundirwa kubazi dist
, uye iyo yepamutemo kuvaka uye kutumira ichaenda online.
Ehe, kuita zviri pamusoro apa zvinoda kunyora mamwe magadzirirwo.
Unogona kutarisa kune chaiyo purojekiti scripting yebasa github.com/fcdoc/doc
secrets.I18N_SITE_TOKEN
uye secrets.NPM_TOKEN
mukumisikidzwa inoda kuti iwe ugadzirise zvakavanzika zvakasiyana muiyo kodhi base.
I18N_SITE_TOKEN
i18n.site/token
NPM_TOKEN
chiratidzo chekuburitsa chepakeji npm
npmjs.com uye gadzira chiratidzo chine mvumo yekuburitsa (sezvinoratidzwa pazasi).
Dhairekitori Chimiro
public
Static mafaera ewebhusaiti, senge favicon.ico
, robots.txt
, nezvimwe.
Iyo icon mafaera pano anogona kugadzirwa ne realfavicongenerator.net
.i18n
Pasi pe .i18n
dhairekitori pane mafaira ekugadzirisa, cache yeshanduro, nezvimwe zve i18n.site
Ona chitsauko chinotevera "Configuration" kuti uwane ruzivo.
en
Dhairekitori remutauro wemabviro, rinoenderana en
fromTo
.i18n/conf.yml
yekumisikidza faira
i18n:
fromTo:
en: zh
Ndokumbira utarise kugadziridzwa kweshanduro i18