Skip to content

Commit

Permalink
Having content directory is not neccessary
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhdaware committed May 25, 2020
1 parent 3b3f483 commit f15786b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.2.17

- Having `content` directory is no more neccessary. Ability to build a static site which is not dependent on markdown content.

## 0.2.16

- Fix for dev-server not having right content-type of `.mjs` files.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abell",
"version": "0.2.16",
"version": "0.2.17",
"description": "Abell is a static blog generator that generates blog in Vanilla JavaScript",
"funding": {
"type": "patreon",
Expand Down
28 changes: 17 additions & 11 deletions src/content-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,20 @@ function getContentMetaAll(contentDirectories, contentPath) {
function getBaseProgramInfo() {
// Get configured paths of destination and content
const abellConfigs = getAbellConfigs();
const contentDirectories = getDirectories(abellConfigs.contentPath);
const $contentObj = getContentMetaAll(
contentDirectories,
abellConfigs.contentPath
);
const $contentArray = Object.values($contentObj).sort((a, b) =>
a.$createdAt.getTime() > b.$createdAt.getTime() ? -1 : 1
);
let contentDirectories;
let $contentObj;
let $contentArray;

if (fs.existsSync(abellConfigs.contentPath)) {
contentDirectories = getDirectories(abellConfigs.contentPath);
$contentObj = getContentMetaAll(
contentDirectories,
abellConfigs.contentPath
);
$contentArray = Object.values($contentObj).sort((a, b) =>
a.$createdAt.getTime() > b.$createdAt.getTime() ? -1 : 1
);
}

const contentTemplatePath = path.join(
abellConfigs.sourcePath,
Expand All @@ -112,11 +118,11 @@ function getBaseProgramInfo() {
const programInfo = {
abellConfigs,
contentTemplate: contentTemplate || null,
contentDirectories,
contentDirectories: contentDirectories || [],
contentTemplatePath,
vars: {
$contentArray,
$contentObj,
$contentArray: $contentArray || [],
$contentObj: $contentObj || {},
globalMeta: abellConfigs.globalMeta
},
logs: 'minimum'
Expand Down

0 comments on commit f15786b

Please sign in to comment.