Scan images

This commit is contained in:
LordMathis 2019-10-20 14:46:19 +02:00
parent b2d56cf254
commit e20d5c9697
No known key found for this signature in database
GPG Key ID: 575849FD91CE470C
2 changed files with 20 additions and 4 deletions

View File

@ -1,7 +1,7 @@
@import "../../config/variables.scss";
#coverPage {
background: url(../../config/background.jpg) no-repeat center center fixed;
background: url('/static/background.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;

View File

@ -38,6 +38,11 @@ export class Scanner {
})
}
processImage (filename) {
const filePath = path.join(process.cwd(), config.contentPath, filename)
fs.copyFileSync(filePath, path.join(process.cwd(), 'public/static', filename))
}
processFile (file, data) {
const filePath = path.join(process.cwd(), config.contentPath, file)
const metadata = this.fileMetadata(filePath)
@ -104,11 +109,22 @@ export class Scanner {
(files) => {
const filtered = files.filter(
(file) => (
fs.statSync(path.join(process.cwd(), config.contentPath, file)).isFile() &&
fs.statSync(path.join(process.cwd(), config.contentPath, file)).isFile()
)
)
const images = filtered.filter(
(file) => (
path.extname(file) == '.jpg' || path.extname(file) == '.png' || path.extname(file) == '.gif'
)
)
images.map(this.processImage)
const posts = filtered.filter(
(file) => (
path.extname(file) == '.md'
)
)
return Promise.all(filtered.map(this.readfile))
)
return Promise.all(posts.map(this.readfile))
}
).then(
(files) => {