Skip to content

Commit

Permalink
Add warning for including empty segments or files in optional mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEyo1 committed Apr 18, 2024
2 parents 8253f82 + 2060369 commit 104b46c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/userGuide/syntax/siteNavigationMenus.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ You can **append the `:expanded:` to a <tooltip content="a menu item with sub me

</div>

<div id="examples"></div>
<div id="examples" class="d-none">

You can see an example of a Site Navigation Menu ==on the left side== of <a target="_blank" href="{{ baseUrl }}/userGuide/formattingContents.html">this page</a>.
</div>

<div id="short" class="d-none">

Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/html/includePanelProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ export function processInclude(node: MbNode, context: Context, pageSources: Page
childContext,
} = variableProcessor.renderIncludeFile(actualFilePath, pageSources, node, context, filePath);

if (nunjucksProcessed.trim() === '') {
const warning = `Empty file included in ${context.cwf}:\n`
+ `File: ${actualFilePath} is empty or contains only whitespace`;
logger.warn(warning);
}

let actualContent = nunjucksProcessed;
if (fsUtil.isMarkdownFileExt(path.extname(actualFilePath))) {
actualContent = isInline
Expand Down Expand Up @@ -269,6 +275,10 @@ export function processInclude(node: MbNode, context: Context, pageSources: Page
logger.error(error);

actualContent = cheerio.html(createErrorNode(node, error));
} else if (actualContentOrNull === '') {
const warning = `Empty reference in ${context.cwf}:\n`
+ `Segment '${hash}' in file: ${actualFilePath} is empty`;
logger.warn(warning);
}
}

Expand Down

0 comments on commit 104b46c

Please sign in to comment.