Skip to content

Commit

Permalink
adds custom description
Browse files Browse the repository at this point in the history
  • Loading branch information
smohadjer committed Jul 18, 2023
1 parent e95d987 commit 9604662
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions bin/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const compileFile = function(pathToPage, sourceFolder, targetFolder) {
fs.readFileSync(pathToPage, 'utf8')
)

const getPageTitle = (page_id) => {
const pathToTitles = sourceFolder + '/pageTitle.json';
const getMeta = (metaFile, page_id) => {
const metaPath = path.join(sourceFolder, metaFile);
try {
const titles = fs.readFileSync(pathToTitles, 'utf8');
const titlesJson = JSON.parse(titles);
const page_title = titlesJson[page_id] || titlesJson.index;
return page_title;
const fileContent = fs.readFileSync(metaPath, 'utf8');
const json = JSON.parse(fileContent);
const meta = json[page_id] || json.index;
return meta;
} catch (error) {
console.log(error);
return '';
Expand All @@ -37,7 +37,8 @@ const compileFile = function(pathToPage, sourceFolder, targetFolder) {
const page_id = (subFolder + '/' + filename).substring(1);
const html = template({
pageId: page_id,
pageTitle: getPageTitle(page_id)
pageTitle: getMeta('pageTitle.json', page_id),
pageDescription: getMeta('pageDescription.json', page_id)
});
const pageFolder = targetFolder + subFolder;

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": "build",
"version": "1.0.6",
"version": "1.0.7",
"description": "A frontend build for HTML Websites",
"repository": {
"type": "git",
Expand Down

0 comments on commit 9604662

Please sign in to comment.