node.js制作網站(nodejs制作網站)

2024-01-27    分類: 網站建設

《開源精選》是我們分享Github、Gitee等開源社區(qū)中優(yōu)質項目的欄目,包括技術、學習、實用與各種有趣的內容。本期推薦的 Ghost 是一個基于現(xiàn)代 Node.js 技術堆棧的開源專業(yè)發(fā)布平臺。

Ghost 是一個基于現(xiàn)代 Node.js 技術堆棧的開源專業(yè)發(fā)布平臺,專為需要強大功能、靈活性和性能的團隊而設計。

Ghost特征

特別快

?

?

?

可靠安全

?

?

?

很棒的設計

?

?

?

現(xiàn)代科技

?

?

?

開源

?

?

?

擁有你的品牌+數據

?

?

?

使用自定義域

?

?

?

控制您的網站設計

?

?

?

免審查

?

?

?

內置 SEO 控制

?

?

?

原生 REST API

?

?

?

綜合SDK

?

?

?

內置會員和訂閱
商務功能

?

?

?

適用于任何前端
或靜態(tài)網站框架

?

?

?

如何安裝Ghost

最快的入門方法是在Ghost(Pro)上建立一個站點。如果您正在運行自托管實例,我們強烈建議您使用至少 1GB 內存的 Ubuntu 服務器來運行 Ghost。

本地安裝 Ghost

Ghost-CLI是一個命令行工具,可幫助您快速輕松地安裝和配置 Ghost 以供使用。npm 模塊可以安裝在本地計算機上,npm也可以安裝yarn在本地計算機上,具體取決于您的偏好。

npm install ghost-cli@latest -g

安裝后,您始終可以運行ghost help以查看可用命令的列表。

在您的終端中,cd進入一個空目錄并運行安裝命令:

ghost install local

安裝完成后,您將能夠訪問您的新站點http://localhost:2368并http://localhost:2368/ghost訪問 Ghost Admin。

啟動和停止

Ghost 在單獨的后臺進程中運行并一直運行,直到您停止它或重新啟動計算機。所以你可能會發(fā)現(xiàn)這些命令對使用它很有用:

ghost stop 停止ghostghost start 啟動ghostghost log 查看日志ghost ls 列出所有正在運行的 Ghost 博客

使用 GScan 進行驗證

GScan 是一個驗證 Ghost 主題是否與最新版本的 Ghost 兼容的工具。當主題被上傳或激活時,Ghost 會自動運行這個工具。出于開發(fā)目的,您也可以通過在本地安裝它自己運行這些檢查。

# Install gscan globallynpm install gscan -g# Scan a theme directory for compatibilitygscan /path/to/ghost/content/themes/casper# Scan a theme zip file for compatibilitygscan -z /path/to/downloads/theme.zip

從源代碼安裝 Ghost

首先創(chuàng)建 GitHub 分支:首先,您需要創(chuàng)建Ghost和Ghost-Admin存儲庫的分支。單擊頂部右側的 fork 按鈕,等待在您的個人 GitHub 帳戶上創(chuàng)建副本。

下一步是為本地開發(fā)配置 Git 存儲庫:主 Ghost 存儲庫包含完整的 Ghost 包,包括管理客戶端和默認主題,它們也將自動設置

# First clone Ghost with submodules and make it your working dirgit clone --recurse-submodules git@github.com:TryGhost/Ghost && cd Ghost

重命名

# Rename origin to upstreamgit remote rename origin upstream# Add your fork as an origin, editing in <YourUsername>!git remote add origin git@github.com:<YourUsername>/Ghost.git

因為 Ghost-Admin 是 Ghost 主存儲庫的子模塊存儲庫,所以這里也需要重復相同的步驟來配置 Git。

# Switch to Ghost-Admin dircd core/admin

更新 Ghost-Admin

# Quick check that everything is on latestgit checkout main && git pull upstream main# Then return to Ghost root directorycd ../../

運行設置和安裝

# Only ever run this onceyarn setup

該setup任務將安裝依賴項、初始化數據庫、設置 git 掛鉤和初始化子模塊并運行管理員的第一個構建。

測試

服務器測試

使用 SQlite 運行測試。要使用 MySQL,請在命令前添加NODE_ENV=testing-mysql

yarn test:unit# Run unit testsyarn test:acceptance# Run acceptance testsyarn test:regression# Run regression testsyarn test path/to/test.js# Run a single testyarn test test/unit/helpers# Run a folder of testsyarn test:all# Run all testsyarn lint# Make sure your code doesn't suck

客戶端測試

客戶端測試應始終在core/admin目錄內運行。任何時候yarn dev運行客戶端測試都可以在http://localhost:4200/tests

ember test# Run all tests in Chrome + Firefoxember test --server# Run all tests, leave results open, and watch for changesember test -f 'gh-my-component'# Run tests where `describe()` or `it()` matches supplied argument# Note: Case sensitiveember test --launch=chrome# Run all tests in Chrome onlyember test -s -f 'Acceptance: Settings - General' --launch=chrome# Most useful test comment for continuous local development# Targets specific test of area being worked on# Only using Chrome to keep resource usage minimal故障排除

ERROR: (EADDRINUSE) 無法啟動 Ghost

此錯誤表示 Ghost 已在運行,您需要停止它。

ERROR: ENOENT

這個錯誤意味著提到的文件不存在。

ERROR 錯誤:找不到模塊

安裝未完成。運行yarn:fix。

錯誤:找不到模塊“./build/default/DTraceProviderBindings”

您切換了節(jié)點版本。運行yarn:fix。

ENOENT:沒有這樣的文件或目錄,在錯誤(本機)處顯示 'path/to/favicon.ico'

您的管理客戶端尚未構建。運行yarn dev。

TypeError: Cannot read property 'tagName' of undefined

你不能同時ember test運行yarn dev。在繼續(xù)之前等待測試完成,并在加載管理員之前等待“構建成功”消息。

主題開發(fā)

Ghost 主題使用 Handlebars 模板語言,該語言使用幫助程序在模板(HTML)和任何 JavaScript 邏輯之間建立了強大的分離。這允許主題非???,具有動態(tài)客戶端應用程序,以及作為靜態(tài) HTML 發(fā)送到瀏覽器的服務器端發(fā)布內容。

Ghost 還使用了一個名為的附加庫,該庫express-hbs為 Handlebars 添加了一些附加功能,例如布局和局部。

如果您以前為其他流行平臺構建過主題,那么使用 Ghost 主題層非常容易。本文檔為您提供了為主題創(chuàng)建靜態(tài) HTML 和 CSS 所需的工具,在您需要呈現(xiàn)動態(tài)數據時使用 Handlebars 表達式。
要將 GScan 用作命令行工具,請全局安裝gscannpm 包:

# Install the npm packagenpm install -g gscan# Use gscan <file path> anywhere to run gscan against a foldergscan /path/to/ghost/content/themes/casper# Run gscan on a zip filegscan -z /path/to/download/theme.zip主題推薦

—END—

開源協(xié)議:MIT license

開源地址:https://github.com/TryGhost/Ghost

非常感謝您讀完創(chuàng)新互聯(lián)的這篇文章:"node.js 制作網站(nodejs制作網站)",僅為提供更多信息供用戶參考使用或為學習交流的方便。我們公司提供:網站建設、網站制作、官網建設、SEO優(yōu)化、小程序制作等服務,歡迎聯(lián)系我們提供您的需求。

文章題目:node.js制作網站(nodejs制作網站)
文章出自:http://www.muchs.cn/news42/315792.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供自適應網站、小程序開發(fā)、做網站、手機網站建設商城網站、關鍵詞優(yōu)化

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化