nfts
1.0.0
靜態博客的FTS服務器;在引擎蓋下使用sqlite。
# npm -g i nfts
為了展示如何增強真正的靜態博客,我們將使用ROR博客的回購:
$ git clone https://github.com/rails/weblog.git
$ cd weblog
$ bundle install
$ jekyll s --no-watch
打開http://127.0.0.0.1:4000以瀏覽博客。
從diff終端:
$ cd weblog
$ nfts-create -o db.sqlite3 -p _posts/ _posts/*
$ nfts-server db.sqlite3
測試服務器:
$ curl 'http://localhost:3000/?q=omg'
這應該返回一系列片段。
現在
編輯_includes/navigation.html添加一個將要調用搜索對話框的鏈接:
<li><a id="nfts__dialog_toggle" href="#">Search</a></li>
將web.js文件從NFTS安裝DIR複製到weblog Dir,並將其重命名為nfts.js這是一個w/ 0依賴項的ES6 UMD。
添加到_config.yml :
nfts:
dialog_toggle_btn: '#nfts__dialog_toggle'
parent_container: 'main > article'
server: http://localhost:3000
debounce: 200
將NFT初始化添加到_includes/navigation.html :
<script src="/nfts.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
new NftsDialog(JSON.parse('{{site.nfts | jsonify }}'),
file => { // post
let prefix = NftsDialog.date_fmt(file.slice(0,10))
let basename = file.slice(10+1).replace(/.[^.]+$/, '')
return '{{site.url}}' + '/' + prefix + '/' + basename
})
})
</script>
NFTS集成已完成。重新啟動Jekyll,請確保它已經完成了網站再生並刷新瀏覽器中的博客頁面,請單擊“搜索”並鍵入“ OMG”(您無需按Enter)。
托多。
麻省理工學院