时隔多年重新创建博客

用Publish重新创建了博客,一边搭建,一边记录。

搭建与发布

  • 用源代码安装Publish
$git clone https://github.com/JohnSundell/Publish.git
$cd Publish
$make
  • 创建自己的博客
$mkdir ChengzhenyuBlog
$cd ChengzhenyuBlog 
$publish new
  • 编译及运行
$publish run
  • 修改main.swift
var url = URL(string: "https://chengzhenyu.github.io")!
try ChengzhenyuBlog().publish( //.publish(withTheme: .foundation)
    using: [
        .copyResources(),
        .addMarkdownFiles(),
        .generateHTML(withTheme: .foundation),
        .generateRSSFeed(including: [.posts]),
        .generateSiteMap(),
        .unwrap(.gitHub("chengzhenyu/chengzhenyu.github.io", useSSH: false), PublishingStep.deploy)
        
    ]
)

解决发布到github时遇到的问题

  • 问题:写好了PublishingStep.deploy,执行publish deploy,无法发布到github。没反应!修改ssh 参数后,提示输入username,回车仍然没有反应。
  • 解决方法:添加ssh key
$git config --global user.name “yourname”
$git config --global user.email“your@email.com"
$ssh -keygen -t rsa -C "your@email.com"

一路yes和回车。在.ssh文件夹下生成两个文件,idrsa和idrsa.pub,打开id_rsa.pub,将全部的内容复制,登录github添加ssh key

ssh -T git@github.com

输入yes,回车。

xcode设置成run&deploy

点击Edit Scheme,在Aguments中添加--deploy

博客的初始样子:P

下面这种markdown写法不支持设置图片大小?!

![baby](/images/screenshot-blog-initialversion.png)

最后

第一天,我去河边去打水,丢了我的鞋,我...开始玩Publish...

今天是2022年7月16日,这个博客出生了:)

参考资料

Welcome to Publish, a static site generator built specifically for Swift developers. It enables entire websites to be built using Swift, and supports themes, plugins and tons of other powerful customization options.

Publish是一款专门为Swift开发者打造的静态网站生成器。它使用Swift构建整个网站,并支持主题、插件和其他大量的定制选项。

Today, I'm so glad to share that this website has been migrated to Publish, a static site generator by John Sundell written in Swift! 🎉

By the end of this tutorial, you will be able to use Github Actions to build and deploy a static website generated with Swift on Github Pages.

继续装修博客