Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit de057ed

Browse files
committed
feat(preparation): infer publicPath automatically
1 parent 2881587 commit de057ed

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

packages/fusuma/src/cli/log.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
const chalk = require('chalk');
44

55
function info(type, text) {
6-
console.info(chalk.black.bgCyan(type), chalk.cyan(text));
6+
console.info(chalk.black.bgCyan(` ${type} `), chalk.cyan(text));
77
}
88

99
function warn(type, text) {
10-
console.warn(chalk.black.bgYellow(type), chalk.yellow(text));
10+
console.warn(chalk.black.bgYellow(` ${type} `), chalk.yellow(text));
1111
}
1212

1313
function error(type, text) {
14-
console.error(chalk.black.bgRed(type), chalk.red(text));
14+
console.error(chalk.black.bgRed(` ${type} `), chalk.red(text));
1515
}
1616

1717
module.exports = {

packages/fusuma/src/tasks/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { join, isAbsolute } = require('path');
44
const fusuma = require('../configs/fusumarc');
5-
const { warn } = require('../cli/log');
5+
const { warn, error } = require('../cli/log');
66
const init = require('./init');
77
const start = require('./start');
88
const build = require('./build');
@@ -23,6 +23,16 @@ async function tasks({ type, options }) {
2323
} catch (e) {
2424
warn('config', `it seems fusumarc doesn't exist, you can run "fusuma init" command`);
2525
} finally {
26+
if (config.meta && config.meta.url && config.build && !config.build.publicPath) {
27+
try {
28+
const { pathname } = new URL(config.meta.url);
29+
30+
config.build.publicPath = pathname;
31+
} catch (e) {
32+
error('preparation', `meta.url specified isn't a URL`);
33+
}
34+
}
35+
2636
config = fusuma.combine(config, {
2737
internal: { ...options, basePath, inputDirPath, outputDirPath },
2838
});

samples/advanced/.fusumarc.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
meta:
2+
url: https://hiroppy.github.io/fusuma/advanced
13
slide:
24
chart: true
35
math: true
46
code:
57
languages:
68
- yaml
9+
build:
10+
useCache: false

samples/debug/.fusumarc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
meta:
2-
url: https://slide.hiroppy.me
2+
url: https://hiroppy.github.io/fusuma/debug
33
title: debug
44
description: A place which produces to resolve issues
55
# thumbnail: https://avatars0.githubusercontent.com/u/3367801?s=400&v=4

samples/intro/.fusumarc.yml

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ extends:
1818
css: style.css
1919
build:
2020
useCache: false
21-
publicPath: /fusuma/intro/

0 commit comments

Comments
 (0)