dat-ssg
は、フォルダー内の構成を使用して、 wget
で Web サイトをダウンロードし、コンテンツを以下に公開するコマンド ライン ツールです。
netlify
dat
dat-ssg
より前は、dat で Web サイトをホストするには、Web サイトを手動で編集するか、静的サイト ジェネレーターと CI システムをセットアップして公開することができました。ただし、これにより、CMS が使用できなくなります。 Ghost、Wordpress、Drupal、その他のダイナミック パブリッシング システムであっても。 dat-ssg
を使用すると、最終的にこれらのシステムの使用を開始し、 dat
経由でアクセスできるようにサイトをホストできるようになります。
また、グローバル CDN に適切に展開される、より安価な静的サイト ホスティングを使用したい場合にも非常に役立ちます。
dat-ssg
の場合は、 _"configuration-folder" と"work-folder"という 2 つのフォルダーが必要です。
.out
ファイルと.error
ファイルが保持されます。 dat-ssg
コマンドラインで使用できるwget
とgit
必要です。 wget
はサイトをダウンロードするために使用され、 git
サイトが変更された場合にパブリケーションをトリガーするためにのみ使用されます。
dat-ssg
ターゲット上でホストされるときに正しく見えるように、ダウンロードされたファイル (メタ タグやリンクなど) を書き換えます。
dat-ssg
ノード アプリケーションであり、次を使用して迅速に実行できます。
$ npx dat-ssg --work-folder ./work --configuration-folder ./config
このプロセスは、構成フォルダー内の変更を検索し、ファイルごとにプロセスを開始します。
構成の場合は、末尾が.js
のファイルを構成フォルダーに追加するだけです。
ファイルは次のような JavaScript オブジェクトをエクスポートする必要があります。
module . exports = {
title : "My Site" , // Title to be used in the process, e.g. for the dat config file
description : "This is my homepage" , // Description used for the process, e.g. for the dat config file
domain : "mydomain.com" , // domain to download data from
https : true , // The domain support https
newDomain : "https://targetdomain.org" , // domain of the new site (needed for content-rewrites)
/*
* wget will download all files that are found at the domain's root but there may be extra roots to look for content.
* You need to specify all the roots
*/
roots : [
"/" ,
"/b.html" ,
"/c.html"
] ,
notFound : '/404/' , // Adds '/404/ to the roots and adds 404 configuration to the deployments (netlify, dat,...)
// Interval to look for updates
update : 1000 * 60 * 20 , // Update every 10 minutes
// The process will use following user name to make commits
git : {
email : "[email protected]" ,
name : "The Name"
} ,
// If you want to publish the page to netlify you need to specify this property, else you can skip it!
netlify : {
siteId : "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" , // Id, provided in the netlify setup
production : false , // Publish as production = true, else = false
/*
* Auth token as provided through the netlify user interface, can be also loaded through `process.env`
*/
authToken : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ,
config : `# Optional configuration, see https://docs.netlify.com/configure-builds/file-based-configuration/#sample-file`
} ,
dat : {
// Time to push after changes, in which a hosting service can connect and download the latest update.
pushTime : 1000 * 60 * 2 // 2 minutes
}
}
ファイルを変更するたびに、プロセスが再起動され、デプロイがトリガーされます。
一部の CMS は、JavaScript または CSS リンクにクエリ パラメータを追加します。例: assets/main/css/main.css?v=25be6de7e6
これらのファイルは、wget を使用して、 assets/main/css/main.css@v=25be6de7e6.css
/main/css/main.css@v=25be6de7e6.css に変換されます。 。
netlify.config
でキャッシュ設定を指定して、ファイルを「永久に」キャッシュすることもできます。
[[ headers ]]
for = " /*@v=* "
[ headers . values ]
cache-control = " public, max-age=31536000 "
初めて構成がフェッチされると、ワークフォルダーに新しいデータが作成されます。この新しい dat には新しいリンクが含まれるため、フォルダーを削除するたびに、レプリケーション リンクと dat-dns 設定で使用したリンクを更新する必要があります。
このプロジェクトは、助成契約No825268に基づいて資金提供されたLEDGERプロジェクトの枠組み内で、欧州連合のHorizon 2020研究革新プログラムから資金提供を受けています。
マサチューセッツ工科大学