Total Pageviews

Sunday, 27 October 2024

搭建基于nodejs的静态博客程序gridsome

 cd ~
npm install --global @gridsome/cli
git clone https://github.com/cossssmin/gridsome-starter-briefly
cd gridsome-starter-briefly
yarn

yarn build (此命令就是生成/更新静态网站的根目录的命令。它会在当前目录下生成dist目录,dist目录就是静态网站的根目录)

新建源帖:

cd posts

nano 2024-10-27-happy-festival.md

cat 2024-10-27-happy-festival.md

显示:

---
title: "happy festival"
description: "这是一首歌"
date: 2024-10-27 02:25:43
---
 

此处写正文或html codes.

 注意:title的值在这里只能是英文,不能是中文,否则后面的build步骤会遇到错误。

 $ cd ..

 $ yarn build

 

访问app.netlify.com/drop,点击“browse to upload",

定位到静态网站的根目录:~/gridsome-starter-briefly/dist目录,上传根目录的内容即可。上传完成后,就会得到链接
https://comforting-moonbeam-5058dd.netlify.app/,这就是我托管在netlify.com空间上的静态博客网站的地址

这个程序其实也提供了分页功能,只是首页没显示出来:

https://comforting-moonbeam-5058dd.netlify.app/paginated/

项目地址:

https://github.com/gridsome/gridsome

https://github.com/cossssmin/gridsome-starter-briefly 

演示博客: https://comforting-moonbeam-5058dd.netlify.app/

---------------------------------------------------------------

cd ~
npm install -g node-gyp
git clone https://github.com/cossssmin/gridsome-starter-bleda
cd gridsome-starter-bleda
yarn
yarn build (此命令就是生成/更新静态网站的根目录的命令。它会在当前目录下生成dist目录,dist目录就是静态网站的根目录)

新建源帖:

 $ cd content

$ cd posts

$ nano 2024-10-27-happy-festival.md

$ cat 2024-10-27-happy-festival.md

显示:

---
title: "happy festival"
description: "这是一首歌"
date: 2024-10-27 09:51:43
tags: ['life', 'music']
---

## 快乐的节日 

此处写入html codes.

 (标题需为英文)

$ cd ../..

$ yarn build

访问app.netlify.com/drop,点击“browse to upload",

定位到静态网站的根目录: ~/gridsome-starter-bleda/dist目录,上传根目录的内容即可。上传完成后,就会得到链接

https://friendly-fudge-74c1c6.netlify.app/,这就是我托管在netlify.com空间上的静态博客网站的地址

项目地址:https://github.com/cossssmin/gridsome-starter-bleda ,提供分页功能

演示博客: https://friendly-fudge-74c1c6.netlify.app/

(https://www.gridsome.cn/starters/ ,

https://www.gridsome.cn/starters/vuetify-blog-starter/

https://www.gridsome.cn/starters/gridsome-tailwind-css-and-markdown-starter/

https://www.gridsome.cn/starters/gridsome-dev-b-starter/,https://github.com/barisaksu/devB )

------------

git clone https://github.com/meditatingdragon/starter-gridsome-vuetify
cd starter-gridsome-vuetify
yarn
gridsome build (此步不要运行yarn build. 运行yarn build会遇到错误。这就是生成/更新静态网站的根目录的命令,会在当前目录下,生成dist目录)
cd dist

cd ../articles
nano happy-festival.md
cat happy-festival.md
显示:
---
title: 快乐的节日
published: true
date: 2024-10-29T00:58:00Z
excerpt: 快乐的节日
---

此处写正文或html codes.

cd ~/starter-gridsome-vuetify/
gridsome build

演示网站:https://peppy-kulfi-ea11b0.netlify.app/articles
项目地址: https://github.com/meditatingdragon/starter-gridsome-vuetify
---------------------------------------------------------------------------------------

git clone https://github.com/meditatingdragon/gridsome-tw-fa-forestry-starter

cd gridsome-tw-fa-forestry-starter

yarn

yarn build


帖子的内容是放在content那行,不是放在下面的"---"的下面。

 --------------------------------------------------------------------------------------

 并未搞定所有的这类gridsome项目,比如项目:

https://github.com/gridsome/gridsome-starter-markdown-blog 

https://github.com/gridsome/gridsome-starter-contentful 

https://github.com/drehimself/gridsome-portfolio-starter

都没安装成功。

(Gridsome

学习GridSome要有Vue基础,但比Vue简单,参考官方文档

资源链接:

创建Gridsome项目

环境准备:Node.js(v8.3 +)环境、C++编译环境、Python环境

使用Gridsome脚手架创建项目时,处理图片,如压缩图片的大小、转换图片的格式. 依赖的sharp包很难安装成功,主要原因有两点:
1、里面包含一些C++文件,在安装的时候需要先编译,要有C++编译环境
2、依赖的libvips几十兆,比较大)

 



 

 

 


 

No comments:

Post a Comment