Total Pageviews

Sunday, 3 November 2024

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

 cd ~

git clone https://github.com/bensmithett/tropical
cd tropical
yarn
yarn build
显示:
 Your static site is ready to deploy from dist/static
⚠️   Configure tropical.siteHost in package.json, otherwise links in your JSON Feed won't work!

$ ls ~/tropical/dist/static

显示:
404.html  blog-post-1.html  happy-festival.html  posts.json
assets/   blog-post-2.html  index.html

可见,~/tropical/dist/static就是静态网站的根目录。

新建源帖:

yarn page happy-festival

运行此命令后,源帖happy-festival.mdx就会出现在~/tropical/src/pages/里,然后去编辑源帖happy-festival.mdx .或者这样新建源帖:

cd  ~/tropical/src/pages/

nano yangzhou.mdx

cat yangzhou.mdx

显示:

export const meta = {
  title: '被评为世界No.1,中国最安逸的城市,它排第二,没谁敢称第一',
  tags: ['post'],
  date: '2024-11-03 08:47:00'
}

## 被评为世界No.1,中国最安逸的城市,它排第二,没谁敢称第一

此处写正文或html codes.

cd  ~/tropical/

yarn build

访问https://app.netlify.com/drop ,上传 ~/tropical/dist/static目录的内容,我得到网址:

 https://resonant-mermaid-bb7877.netlify.app/

演示网站:https://resonant-mermaid-bb7877.netlify.app/

项目地址: https://github.com/bensmithett/tropical

官网:https://tropical.js.org/ 

注意:要预览网站效果时,进入静态网站的根目录后,最好运行serve -l 1234 (由npm install -g serve得到的那个可执行文件serve),然后访问

http://127.0.0.1:1234 ,里面的链接,比如http://127.0.0.1:1234/ce就是可以正常访问的,而无需在网址的最后面加上 .html 才能访问。

如果运行python3 -m http.server 1234 ,就需在网址的最后面加上 .html 才能正常访问.

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

还可这样做:

首先fork这个项目https://github.com/bensmithett/tropical,我fork后的项目地址是

https://github.com/briteming/tropical,然后访问https://github.com/briteming/tropical/tree/main/src/pages ,在此新建一些源帖。然后导入项目https://github.com/briteming/tropical到vercel.com/new. 在build and output settings那步,编辑Output Directory的值为

dist/static ,然后点击deploy按钮,等待部署完成,部署完成后,我得到网址:

https://tropical-hixi.vercel.app/ (和https://tropical-rwij.vercel.app/,我导入了2次,各得到一个网址)。不过网址里面的链接有点问题,比如https://tropical-hixi.vercel.app/zashi/ ,要改成https://tropical-hixi.vercel.app/zashi.html 才行。

或者,也可导入项目https://github.com/briteming/tropical到https://app.netlify.com/start ,

在Build settings那一部分,Base directory的值为./ , Build command的值为npm run build ,

Publish directory的值为./dist/static , 然后点击deploy按钮,等待部署完成。部署完成后,我得到网址https://tpc-site.netlify.app/ ,https://tropical-site.netlify.app/(我导入了2次,各得到

一个网址。)

vercel.app网址里面的链接有点问题,但netlify.app网址里面的链接没有任何问题。

项目地址: https://github.com/bensmithett/tropical

https://github.com/briteming/tropical

演示网址: 

https://tropical-hixi.vercel.app

https://tropical-rwij.vercel.app/

https://tpc-site.netlify.app/

https://tropical-site.netlify.app/

 

 

 

 

 


 

 

No comments:

Post a Comment