Skip to content

Commit

Permalink
feat: initialize Hexo site
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Mar 27, 2023
1 parent bb5b6b3 commit 3d57d32
Show file tree
Hide file tree
Showing 230 changed files with 19,477 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
sh.exe.stackdump

*.log
node_modules/

.cache/
Expand All @@ -11,3 +12,10 @@ src/jekyll/_data/knosys/
src/jekyll/_knosys/
src/jekyll/_assets/*/ksio/
src/jekyll/_site/

src/hexo/themes/lime/source/*/ksio/
src/hexo/Thumbs.db
src/hexo/db.json
src/hexo/public/
src/hexo/.deploy*/
src/hexo/_multiconfig.yml
34 changes: 27 additions & 7 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,40 @@ const { ensureDirExists, copyFileDeeply, readData, saveData, execute } = require

const SRC_ROOT = resolvePath(__dirname, '../src');
const SA_ROOT = `${SRC_ROOT}/standalone`;
const JEKYLL_ROOT = `${SRC_ROOT}/jekyll`;

function buildJekyllAssets() {
function copyAssets(distRoot, polyfill) {
['fonts', 'images', 'javascripts', 'stylesheets'].forEach(dirName => {
const assetsPath = `${JEKYLL_ROOT}/_assets/${dirName}`;
const assetsPath = `${distRoot}/${dirName}`;

ensureDirExists(assetsPath);

const srcPath = `${SA_ROOT}/${dirName}`;
const distPath = `${JEKYLL_ROOT}/_assets/${dirName}/ksio`;
const distPath = `${distRoot}/${dirName}/ksio`;

ensureDirExists(distPath, true);
copyFileDeeply(srcPath, distPath);
copyFileDeeply(srcPath, distPath, polyfill ? [] : ['polyfills']);
});

const shareSnsStyleFilePath = `${JEKYLL_ROOT}/_assets/stylesheets/ksio/vendors/share.scss`;
const distStyleDirPath = `${distRoot}/stylesheets/ksio/`;
const shareSnsStyleFilePath = `${distStyleDirPath}/vendors/share.scss`;

saveData(shareSnsStyleFilePath, readData(shareSnsStyleFilePath).replace(new RegExp('fonts/vendors/share', 'g'), 'ksio/vendors/share'));

if (!polyfill) {
return;
}

['_all', '_bootstrap-custom', '_helper', '_painter'].forEach(fileName => {
const filePath = `${distStyleDirPath}/${fileName}.scss`;

saveData(
filePath,
readData(filePath)
.replace(new RegExp('@import "compass', 'g'), '@import "./polyfills/compass')
.replace(new RegExp('@import "bootstrap', 'g'), '@import "./polyfills/bootstrap')
.replace(new RegExp('@import "font-awesome', 'g'), '@import "./polyfills/font-awesome'),
);
});
}

module.exports = {
Expand All @@ -31,7 +47,11 @@ module.exports = {
}

if (type === 'jekyll') {
return buildJekyllAssets();
return copyAssets(`${SRC_ROOT}/jekyll/_assets`);
}

if (type === 'hexo') {
return copyAssets(`${SRC_ROOT}/hexo/themes/lime/source`, true);
}
},
};
14 changes: 14 additions & 0 deletions bin/serve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { resolve: resolvePath } = require('path');
const { execSync } = require('child_process');

const { execute } = require('./helper');

module.exports = {
execute: (type = 'jekyll') => {
if (type === 'hexo') {
return execSync('npm run server', { cwd: resolvePath(__dirname, '../src/hexo'), stdio: 'inherit' });
}

execute('site', 'serve');
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "node bin build",
"clean": "rm -rf src/jekyll/.asset-cache",
"start": "node bin site serve",
"start": "node bin serve",
"predeploy": "npm run clean",
"deploy": "node bin site deploy"
},
Expand Down
105 changes: 105 additions & 0 deletions src/hexo/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Hexo
subtitle: ''
description: ''
keywords:
author: John Doe
language: en
timezone: ''

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http:https://example.com
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
enable: true # Open external links in new tab
field: site # Apply to the whole site
exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
prismjs:
enable: false
preprocess: true
line_number: true
tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: '/'
per_page: 10
order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http:https://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: lime

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: ''

0 comments on commit 3d57d32

Please sign in to comment.