Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ Page.prototype.collectFrontMatter = function (includedPage) {
this.frontMatter.src = this.src;
// Title specified in site.json will override title specified in front matter
this.frontMatter.title = (this.title || this.frontMatter.title || '');
// Layout specified in front matter will override layout specified in site.json
this.frontMatter.layout = (this.frontMatter.layout || this.layout || '');
// Layout specified in site.json will override layout specified in the front matter
this.frontMatter.layout = (this.layout || this.frontMatter.layout || LAYOUT_DEFAULT_NAME);
} else {
// Page is addressable but no front matter specified
this.frontMatter = {
Expand Down
4 changes: 2 additions & 2 deletions src/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,15 +602,15 @@ Site.prototype.generatePages = function () {
faviconUrl,
pageSrc: page.src,
title: page.title,
layout: page.layout || LAYOUT_DEFAULT_NAME,
layout: page.layout,
searchable: page.searchable !== 'no',
}));
} else {
this.pages = addressablePages.map(page => this.createPage({
faviconUrl,
pageSrc: page.src,
title: page.title,
layout: page.layout || LAYOUT_DEFAULT_NAME,
layout: page.layout,
searchable: page.searchable !== 'no',
}));
}
Expand Down
19 changes: 14 additions & 5 deletions test/test_site/expected/siteData.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"footer": "footer.md",
"siteNav": "site-nav.md",
"head": "myCustomHead.md, myCustomHead2.md",
"layout": "default",
"src": "index.md"
"src": "index.md",
"layout": "default"
},
{
"headings": {},
Expand All @@ -73,12 +73,21 @@
},
{
"headings": {
"uses-a-layout": "Uses a layout"
"uses-a-front-matter-layout": "Uses a front matter layout"
},
"title": "Hello World",
"head": "overwriteLayoutHead.md",
"layout": "testLayout",
"src": "testLayouts.md"
},
{
"headings": {
"uses-a-site.json-layout%2C-overriding-front-matter": "Uses a site.json layout, overriding front matter"
},
"title": "Hello World",
"head": "overwriteLayoutHead.md",
"src": "testLayouts.md",
"layout": "testLayout"
"layout": "testLayout",
"src": "testLayoutsOverride.md"
},
{
"headings": {
Expand Down
2 changes: 1 addition & 1 deletion test/test_site/expected/testLayouts.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>
<div id="page-content">
<div id="content-wrapper">
<h1 id="uses-a-layout">Uses a layout<a class="fa fa-anchor" href="#uses-a-layout"></a></h1>
<h1 id="uses-a-front-matter-layout">Uses a front matter layout<a class="fa fa-anchor" href="#uses-a-front-matter-layout"></a></h1>
</div>
</div>
</div>
Expand Down
58 changes: 58 additions & 0 deletions test/test_site/expected/testLayoutsOverride.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello World</title>
<link rel="stylesheet" href="markbind\css\bootstrap.min.css">
<link rel="stylesheet" href="markbind\css\bootstrap-vue.min.css">
<link rel="stylesheet" href="markbind\css\font-awesome.min.css" >
<link rel="stylesheet" href="markbind\css\bootstrap-glyphicons.min.css" >
<link rel="stylesheet" href="markbind\css\github.min.css">
<link rel="stylesheet" href="markbind\css\markbind.css">
<link rel="stylesheet" href="markbind\layouts\testLayout\styles.css">

<script src="/test_site/headFiles/overwriteLayoutScript.js"></script>
<link rel="icon" href="/test_site/favicon.png">
</head>
<body>
<div id="app">
<div id="flex-body">
<div id="site-nav">
<ul style="list-style-type: none; margin-left:-1em">
<li style="margin-top: 10px">[Layout Nav]</li>
</ul>
</div>
<div id="site-nav-btn-wrap">
<div id="site-nav-btn">
<div class="menu-top-bar"></div>
<div class="menu-middle-bar"></div>
<div class="menu-bottom-bar"></div>
</div>
</div>
<div id="page-content">
<div id="content-wrapper">
<h1 id="uses-a-site.json-layout%2C-overriding-front-matter">Uses a site.json layout, overriding front matter<a class="fa fa-anchor" href="#uses-a-site.json-layout%2C-overriding-front-matter"></a></h1>
</div>
</div>
</div>
<div id="flex-div"></div>
<footer>
<div class="text-center">
Layout footer
</div>
</footer>
</div>
</body>
<script src="markbind\js\vue.min.js"></script>
<script src="markbind\js\vue-strap.min.js"></script>
<script src="markbind\js\polyfill.min.js"></script>
<script src="markbind\js\bootstrap-vue.min.js"></script>
<script>
const baseUrl = '/test_site'
</script>
<script src="markbind\js\setup.js"></script>
<script src="markbind\layouts\testLayout\scripts.js"></script>
</html>
1 change: 0 additions & 1 deletion test/test_site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: Hello World
footer: footer.md
siteNav: site-nav.md
head: myCustomHead.md, myCustomHead2.md
layout: default
</frontmatter>

<include src="components/header.md" />
Expand Down
7 changes: 5 additions & 2 deletions test/test_site/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"pages": [
{
"src": "index.md",
"title": "Hello World",
"layout": "testLayout"
"title": "Hello World"
},
{
"src": "testEmptyFrontmatter.md",
Expand All @@ -15,6 +14,10 @@
},
{
"src": "testLayouts.md",
"title": "Hello World"
},
{
"src": "testLayoutsOverride.md",
"title": "Hello World",
"layout": "testLayout"
},
Expand Down
3 changes: 2 additions & 1 deletion test/test_site/testLayouts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<frontmatter>
title: Test Layouts
head: overwriteLayoutHead.md
layout: testLayout
</frontmatter>

# Uses a layout
# Uses a front matter layout

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In site.json, no layout is specified.
In the frontmatter, testLayout is specified.
The final output still uses default instead of testLayout.

That doesn't seem right. 😕

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like the default should have the lowest priority.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, fixed it, there was some issue with the glob layouts

7 changes: 7 additions & 0 deletions test/test_site/testLayoutsOverride.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<frontmatter>
title: Test Layouts
head: overwriteLayoutHead.md
layout: default
</frontmatter>

# Uses a site.json layout, overriding front matter