@tenjuu99/blog 0.2.29 → 0.2.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dev-server +7 -10
- package/lib/dir.js +19 -25
- package/package.json +1 -1
- package/packages/breadcrumbs/helper/breadcrumbs.js +2 -2
package/bin/dev-server
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawn } from 'child_process'
|
|
4
|
-
import { srcDir, watch as watchDir, packageDir, packageDirCore } from '../lib/dir.js'
|
|
4
|
+
import { srcDir, watch as watchDir, packageDir, packageDirCore, watchCallback } from '../lib/dir.js'
|
|
5
5
|
import { watchers, watch } from '../lib/watcher.js'
|
|
6
6
|
import generate from '../lib/generate.js'
|
|
7
7
|
import path from 'path'
|
|
@@ -12,19 +12,16 @@ const libDir = path.dirname(__filename) + '/../lib/'
|
|
|
12
12
|
const binDir = path.dirname(__filename) + '/../bin/'
|
|
13
13
|
|
|
14
14
|
watchers.push({
|
|
15
|
-
paths: srcDir,
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
paths: [srcDir],
|
|
16
|
+
event: ['change', 'add', 'unlink'],
|
|
17
|
+
callback: (path) => {
|
|
18
|
+
watchCallback(path)
|
|
19
|
+
generate()
|
|
18
20
|
},
|
|
19
|
-
callback: generate
|
|
20
|
-
})
|
|
21
|
-
watchers.push({
|
|
22
|
-
paths: watchDir.pageDir,
|
|
23
|
-
callback: generate,
|
|
24
21
|
watchOptions: {
|
|
25
22
|
ignoreInitial: true
|
|
26
23
|
},
|
|
27
|
-
|
|
24
|
+
prior: true,
|
|
28
25
|
})
|
|
29
26
|
watchers.push({
|
|
30
27
|
paths: [watchDir.serverDir, watchDir.helperDir, libDir, packageDir, packageDirCore],
|
package/lib/dir.js
CHANGED
|
@@ -99,30 +99,23 @@ const resolveDestinationPath = (path) => {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
watchOptions: {
|
|
122
|
-
ignoreInitial: true
|
|
123
|
-
},
|
|
124
|
-
prior: true,
|
|
125
|
-
})
|
|
102
|
+
const watchCallback = ( path ) => {
|
|
103
|
+
const dest = resolveDestinationPath(path)
|
|
104
|
+
if (!dest) {
|
|
105
|
+
console.log(styleText('red', `[watcher] cannot resolve destination path: ${path}`))
|
|
106
|
+
alreadyCached = false
|
|
107
|
+
cache()
|
|
108
|
+
return true
|
|
109
|
+
}
|
|
110
|
+
if (fs.existsSync(path)) {
|
|
111
|
+
fs.cpSync(path, dest, { force: true })
|
|
112
|
+
console.log(styleText('blue', `update ${path} => ${dest}`))
|
|
113
|
+
} else {
|
|
114
|
+
fs.unlinkSync(dest)
|
|
115
|
+
console.log(styleText('red', `unlink ${dest}`))
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
126
119
|
export {
|
|
127
120
|
rootDir,
|
|
128
121
|
srcDir,
|
|
@@ -136,5 +129,6 @@ export {
|
|
|
136
129
|
watch,
|
|
137
130
|
cache,
|
|
138
131
|
packageDir,
|
|
139
|
-
packageDirCore
|
|
132
|
+
packageDirCore,
|
|
133
|
+
watchCallback
|
|
140
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { allData, config } from '@tenjuu99/blog'
|
|
2
2
|
|
|
3
|
-
export function breadcrumbList(pageName) {
|
|
3
|
+
export function breadcrumbList(pageName, topPageName = 'top') {
|
|
4
4
|
const pageData = allData[pageName]
|
|
5
5
|
const entries = Object.entries(allData)
|
|
6
6
|
const breadCrumbs = ['/']
|
|
@@ -28,7 +28,7 @@ export function breadcrumbList(pageName) {
|
|
|
28
28
|
|
|
29
29
|
const output = breadCrumbs.map(v => {
|
|
30
30
|
const href = config.relative_path ? config.relative_path + v[0] : v[0]
|
|
31
|
-
return `<div class="breadcrumbs-item"><a href="${href}">${v[0] === '/' ?
|
|
31
|
+
return `<div class="breadcrumbs-item"><a href="${href}">${v[0] === '/' ? topPageName : v[1]}</a></div>`
|
|
32
32
|
}).join('') + `<div class="breadcrumbs-item">${last[1]}</div>`
|
|
33
33
|
return '<div class="breadcrumbs">'
|
|
34
34
|
+ output
|