Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
Fix generated pathing for page subgen
Browse files Browse the repository at this point in the history
  • Loading branch information
larsonjj committed Aug 5, 2019
1 parent cdecd62 commit 39edf7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions generators/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ module.exports = class extends Generator {
});

this.name = 'no-name';
this.urlPath = '';
if (this.arguments[0]) {
this.name = this.arguments[0];
this.urlPath = this.name.split('/').reduce((acc, ele, i) => {
return acc + '../';
}, '');
}

this.layout = 'base';
Expand Down Expand Up @@ -54,6 +58,7 @@ module.exports = class extends Generator {
const templateData = {
_: _,
name: this.name,
urlPath: this.urlPath,
layout: this.layout,
layoutDir: this.layoutDir
};
Expand Down
2 changes: 1 addition & 1 deletion generators/page/templates/page.nunjucks
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block config %}
{# Correct base url pathing for this page #}
{% set baseUrl = '../' %}
{% set baseUrl = '<%= urlPath %>' %}
{% endblock %}

{% block content %}
Expand Down
4 changes: 2 additions & 2 deletions generators/page/templates/page.pug
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extends ../<%= layoutDir %>/<%= layout %>
extends <%= urlPath %><%= layoutDir %>/<%= layout %>

block config
//- Correct base url pathing for this page
- var baseUrl = '../'
- var baseUrl = '<%= urlPath %>'

block content
p <%= name.toLowerCase() %> page

0 comments on commit 39edf7f

Please sign in to comment.