-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
263 additions
and
14,695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,79 @@ | ||
# 立泉の写字板 | ||
|
||
这是一个基于`Jekyll`的开源[博客](https://mudan.me)示例,遵循[Material Design](https://material.io)设计规范,使用`Google`的[Material components web](https://github.com/material-components/material-components-web)组件库。 | ||
一个基于[Jekyll](https://jekyllrb.com)的[Material Design](https://material.io)开源博客,使用`Google`提供的[Material Components Web](https://github.com/material-components/material-components-web)组件库。 | ||
|
||
淡雅极简风,文字、色彩、动画之外不添加多余元素,这也是我自己的博客。 | ||
这是我自己的博客网站,它并非通用`Jekyll`模版,而是包含了太多我个人倾向的私人分享空间,淡红色极简风,文字、色彩、动画之外不添加多余元素,可以把它当作一个使用`Material Design`的个人站参考。 | ||
|
||
博文使用`Markdown`格式撰写,由`Jekyll`将其按照指定的方式转换为`HTML`网页,生成一个静态站点,可以托管在[GitHub Pages](https://pages.github.com)或更灵活的云服务器上。 | ||
博客链接 👉 [立泉の写字板](https://mudan.me) | ||
|
||
![立泉の写字板](https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/screenshot_index.webp) | ||
|
||
博文使用`Markdown`格式撰写,由`Jekyll`将其按指定方式转换为`HTML`网页,生成静态站点,可以托管在[GitHub Pages](https://pages.github.com)或更灵活的云服务器上。 | ||
|
||
![立泉の写字板](https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/screenshot_essay_phone.webp) | ||
|
||
# 本地调试 | ||
|
||
切换到内部的`npm`工程目录,构建生成所需的`js`、`css`文件: | ||
首先切换到内部`webpack`工程目录,构建所需的`js`、`css`文件: | ||
|
||
```sh | ||
# 进入内部npm工程 | ||
# 进入内部webpack工程 | ||
cd npm | ||
# 安装所需依赖 | ||
npm install | ||
# 构建,在/npm/dist/目录下生成js和css | ||
# 在/npm/dist/目录下生成js和css | ||
npm run build | ||
``` | ||
|
||
在`_includes/head-common.html`中定义着网站使用的`js`和`css`,它们由内部的`npm`工程生成,为提高访问速度而被托管到阿里云`OSS`上。 | ||
`_includes/head-common.html`中定义着网站使用的`js`和`css`资源,它们由内部`webpack`工程生成,为提高访问速度而被托管到阿里云`OSS`上。 | ||
|
||
本地调试时,需要修改这些资源为本地文件以实时响应`npm`工程的变化: | ||
本地调试时,需要进入`debug`模式使用上面👆生成的本地资源以实时响应`webpack`工程变化: | ||
|
||
```html | ||
<!-- _includes/head-common.html --> | ||
|
||
<!-- css和js文件由内部的npm工程输出 --> | ||
<!-- only for test --> | ||
<link rel="stylesheet" href="/npm/dist/apqx.v[version].css" /> | ||
<script type="text/javascript" src="/npm/dist/apqx.v[version].js"></script> | ||
<link rel="stylesheet" href="/css/materialFontsIcons.css" /> | ||
|
||
<!-- 这里用Jekyll的Liquid模版语言隐藏掉这段指向阿里云托管的外部资源的代码 --> | ||
{% comment %} | ||
<!-- for publish --> | ||
<link rel="stylesheet" href="https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/apqx.v[version].css" /> | ||
<script type="text/javascript" src="https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/apqx.v[version].js"></script> | ||
<link rel="stylesheet" href="https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/materialFontsIcons.css" /> | ||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<!-- close it when on test --> | ||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GDLCDFZXBF"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag() { dataLayer.push(arguments); } | ||
gtag('js', new Date()); | ||
gtag('config', 'G-GDLCDFZXBF'); | ||
</script> | ||
{% endcomment %} | ||
<!-- 设置debug为true,将会使用本地资源 --> | ||
{% assign debug = true %} | ||
``` | ||
|
||
安装[Jekyll](https://jekyllrb.com/docs/installation/macos/)后,启动本地服务: | ||
安装[Jekyll](https://jekyllrb.com/docs/installation/macos/),启动本地服务: | ||
|
||
```sh | ||
# 安装jekyll,macOS使用home-brew | ||
# 安装jekyll,macOS使用Homebrew | ||
brew install jekyll | ||
# 安装定义在_config.yml中的jekyll插件 | ||
# 安装config.yml中定义的jekyll插件 | ||
bundle install | ||
# 启动jekyll服务,同时自动调用浏览器打开http://localhost:4000 | ||
# 启动jekyll服务 | ||
# 同时自动调用浏览器打开http://localhost:4000进入博客 | ||
bundle exec jekyll serve -l -o | ||
``` | ||
|
||
`Jekyll`会在`_site/`目录下生成一个由静态`HTML`页面构成的网站源码,浏览器访问本地`4000`端口就可以看到这个博客网站了。 | ||
`Jekyll`会在`_site/`目录下生成一个由`HTML`页面构成的静态网站,并`serve`到本地4000端口,通过这个👇链接访问: | ||
|
||
`http://localhost:4000` | ||
```sh | ||
http://localhost:4000 | ||
``` | ||
|
||
# 部署到GitHub Pages | ||
|
||
对于部署到[GitHub Pages](https://pages.github.com)的情况,因为中国大陆的访问速度受限,一般会把`HTML`网页之外的资源托管到大陆的云平台上以提高国内访问速度,比如阿里云的`OSS`对象存储服务。 | ||
因为[GitHub Pages](https://pages.github.com)在中国大陆受限,所以一般会把`HTML`页面里的资源托管到大陆的云平台上以提高国内访问速度,比如阿里云的`OSS`对象存储服务。如果域名已备案也可以再叠一层`CDN`加速。 | ||
|
||
本地调试完成后,如果`npm`工程生成了新的`js`和`css`文件,需要更新阿里云`OSS`托管的旧文件,修改`_includes/head-common.html`以使用这些云端托管的资源。 | ||
本地调试完成后,如果`webpack`生成了新的`js`和`css`,需要上传到`OSS`托管,然后修改`_includes/head-common.html`关闭`debug`模式即可使用这些托管的资源。 | ||
|
||
```html | ||
<!-- _includes/head-common.html --> | ||
|
||
<!-- css和js文件由内部的npm工程输出 --> | ||
<!-- 这里用Jekyll的Liquid模版语言隐藏掉这段指向本地资源的代码 --> | ||
{% comment %} | ||
<!-- only for test --> | ||
<link rel="stylesheet" href="/npm/dist/apqx.v[version].css" /> | ||
<script type="text/javascript" src="/npm/dist/apqx.v[version].js"></script> | ||
<link rel="stylesheet" href="/css/materialFontsIcons.css" /> | ||
{% endcomment %} | ||
|
||
<!-- for publish --> | ||
<link rel="stylesheet" href="https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/apqx.v[version].css" /> | ||
<script type="text/javascript" src="https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/apqx.v[version].js"></script> | ||
<link rel="stylesheet" href="https://apqx-host.oss-cn-hangzhou.aliyuncs.com/blog/materialFontsIcons.css" /> | ||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<!-- close it when on test --> | ||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GDLCDFZXBF"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag() { dataLayer.push(arguments); } | ||
gtag('js', new Date()); | ||
gtag('config', 'G-GDLCDFZXBF'); | ||
</script> | ||
<!-- 设置debug为false,将使用云端托管资源 --> | ||
{% assign debug = false %} | ||
``` | ||
|
||
把本地修改`commit`后`push`到自己的`GitHub repository`上,`GitHub Pages`会自动执行`Jekyll`的编译操作,就像本地调试时那样把`Markdown`文章转换为`HTML`页面并更新到指定的域名下。 | ||
本地修改`commit`后`push`到自己的`GitHub repository`,`GitHub Pages`会自动执行`Jekyll`的`build`操作,就像本地调试那样把`Markdown`文章转换为`HTML`页面并`serve`到指定域名下。 | ||
|
||
```sh | ||
# 本地commit | ||
git commit | ||
# push到自己的Github repository上 | ||
# push到自己的Github repository | ||
git push origin | ||
``` | ||
|
||
等待数秒或数分钟,取决于`Pages`等待执行的任务量,完成后`Pages`上的网页就会更新。 | ||
静候数秒或数分钟,取决于`Pages`等待执行的任务量,完成后`Pages`上的网页就会更新。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<!-- Only for debug, host on local --> | ||
<link rel="stylesheet" href="{{ "/npm/dist/apqx-v2.1.6.css" }}" /> | ||
<script type="text/javascript" src="{{ "/npm/dist/apqx-v2.1.6.js" }}"></script> | ||
<link rel="stylesheet" href="/npm/dist/apqx-v{{ version }}.css" /> | ||
<script type="text/javascript" src="/npm/dist/apqx-v{{ version }}.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.