main
HerrHase 2 years ago
parent 92af1ee3a3
commit bacef6a2a6

@ -0,0 +1,14 @@
---
title: "Data"
---
## Normcore cold-pressed ramps DSA
Normcore cold-pressed ramps DSA yes plz hot chicken green juice succulents leggings messenger bag truffaut iceland pabst ethical godard. Semiotics air plant marfa, drinking vinegar authentic iceland pug fit cloud bread cronut kickstarter glossier crucifix tumeric. Chicharrones polaroid flexitarian, seitan lumbersexual viral fam master cleanse four dollar toast scenester. Succulents poutine vegan keffiyeh meh, health goth DIY tattooed. Praxis roof party celiac chartreuse banjo butcher you probably haven't heard of them schlitz beard. Ethical tattooed kinfolk, cliche vegan messenger bag mukbang dreamcatcher cloud bread farm-to-table gatekeep trust fund.
## Palo santo leggings normcore aesthetic
bicycle rights sartorial godard slow-carb thundercats art party cray JOMO. Truffaut four dollar toast hoodie pour-over. Fanny pack iPhone jean shorts tote bag, master cleanse succulents tbh fixie gatekeep pok pok letterpress cornhole. Dreamcatcher tattooed hot chicken gatekeep, glossier salvia 8-bit cred. Fit lomo chillwave cold-pressed humblebrag narwhal. Meggings edison bulb fanny pack irony af pug pok pok whatever vexillologist vibecession cred butcher trust fund chia.
## Bitters kale chips chambray activated charcoal
wolf keffiyeh hell of selfies. Wolf readymade shoreditch flexitarian venmo single-origin coffee, knausgaard fit actually street art cold-pressed iPhone gatekeep. Migas bruh adaptogen semiotics marfa pickled yuccie. Locavore normcore lomo, shoreditch fashion axe actually glossier iPhone photo booth blue bottle DIY XOXO williamsburg. Pinterest whatever taxidermy, kale chips prism XOXO schlitz twee tote bag woke swag. Wayfarers fashion axe heirloom humblebrag synth. Whatever succulents PBR&B, pop-up enamel pin echo park tonx stumptown taiyaki.

@ -53,7 +53,7 @@ class Blocks {
*/ */
_findFiles(dirPath, parent = '') { _findFiles(dirPath, parent = '') {
// // getting block files
const files = fs.readdirSync(dirPath, { const files = fs.readdirSync(dirPath, {
withFileTypes: true withFileTypes: true
}) })
@ -62,7 +62,7 @@ class Blocks {
// skip for file that is not markdown // skip for file that is not markdown
if (file.isFile() && path.extname(file.name) !== this.FILE_EXTENSION) { if (file.isFile() && path.extname(file.name) !== this.FILE_EXTENSION) {
return; return
} }
// if directory going deep // if directory going deep
@ -75,18 +75,22 @@ class Blocks {
// skip if empty // skip if empty
if (!fileString) { if (!fileString) {
return; return
} }
// create page object and add to page // create page object and add to page
const block = new BlockFactory(fileString) const block = new BlockFactory(fileString)
const blockname = this._parseBlockname(file.name) const blockname = this._parseBlockname(file.name)
if (this._isArray(file.name)) {
if (!this._results[blockname]) { if (!this._results[blockname]) {
this._results[blockname] = [] this._results[blockname] = []
} }
this._results[blockname].push(block.get()) this._results[blockname].push(block.get())
} else {
this._results[blockname] = block.get()
}
}) })
} }
@ -102,6 +106,18 @@ class Blocks {
return filename.replace(regex, '') return filename.replace(regex, '')
} }
/**
* remove '.md' and also ordering number = filename
*
* @param {string} filename
* @return {string}
*
*/
_isArray(filename) {
const regex = new RegExp(/[-_]?[0-9]\b.md\b$/)
return regex.test(filename)
}
/** /**
* get file content * get file content
* *

@ -1,7 +1,7 @@
const { assert } = require('chai') const { assert } = require('chai')
const fs = require('fs') const fs = require('fs')
describe('Blocks', function () { describe('Blocks / Array', function () {
// get function parseMarkdownFile // get function parseMarkdownFile
const BlocksQuery = require('./../src/queries/blocks.js') const BlocksQuery = require('./../src/queries/blocks.js')
@ -22,3 +22,21 @@ describe('Blocks', function () {
assert.equal(results.block[0].title, 'health goth DIY tattooed') assert.equal(results.block[0].title, 'health goth DIY tattooed')
}) })
}) })
describe('Blocks / Single', function () {
// get function parseMarkdownFile
const BlocksQuery = require('./../src/queries/blocks.js')
const blocksQuery = new BlocksQuery('./ressources')
const results = blocksQuery.find()
// check results
it('block is array', function() {
assert.isObject(results.data)
})
it('block has length of 2', function() {
assert.equal(results.data.title, 'Data')
})
})

Loading…
Cancel
Save