From 5ced99356653b85ceb13c79800d7683fca950053 Mon Sep 17 00:00:00 2001 From: Justin Fagnani Date: Fri, 20 Dec 2019 13:36:46 -0800 Subject: [PATCH] Fix URLs fully with relative path helper --- docs-src/_includes/example.11ty.cjs | 3 ++- docs-src/_includes/nav.11ty.cjs | 12 +++++++----- docs-src/_includes/page.11ty.cjs | 12 +++++++----- docs-src/_includes/relative-path.cjs | 9 +++++++++ docs/api/index.html | 8 ++++---- docs/examples/index.html | 12 ++++++------ docs/examples/name-property/index.html | 18 +++++++++--------- docs/index.html | 14 +++++++------- docs/install/index.html | 8 ++++---- 9 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 docs-src/_includes/relative-path.cjs diff --git a/docs-src/_includes/example.11ty.cjs b/docs-src/_includes/example.11ty.cjs index b972e71..9e98890 100644 --- a/docs-src/_includes/example.11ty.cjs +++ b/docs-src/_includes/example.11ty.cjs @@ -1,4 +1,5 @@ const page = require('./page.11ty.cjs'); +const relative = require('./relative-path.cjs'); /** * This template extends the page template and adds an examples list. @@ -21,7 +22,7 @@ const renderExample = ({name, content, collections, page}) => { ? '' : collections.example.map((post) => `
  • - ${ post.data.description.replace('<', '<') } + ${post.data.description.replace('<', '<')}
  • `).join('')} diff --git a/docs-src/_includes/nav.11ty.cjs b/docs-src/_includes/nav.11ty.cjs index 4213048..4e7fb23 100644 --- a/docs-src/_includes/nav.11ty.cjs +++ b/docs-src/_includes/nav.11ty.cjs @@ -1,9 +1,11 @@ -module.exports = function(data) { +const relative = require('./relative-path.cjs'); + +module.exports = function({page}) { return ` `; }; diff --git a/docs-src/_includes/page.11ty.cjs b/docs-src/_includes/page.11ty.cjs index 7b57514..f37c5e7 100644 --- a/docs-src/_includes/page.11ty.cjs +++ b/docs-src/_includes/page.11ty.cjs @@ -1,8 +1,10 @@ const header = require('./header.11ty.cjs'); const footer = require('./footer.11ty.cjs'); const nav = require('./nav.11ty.cjs'); +const relative = require('./relative-path.cjs'); module.exports = function(data) { + const {title, page, content} = data; return ` @@ -10,18 +12,18 @@ module.exports = function(data) { - ${data.title} - + ${title} + - - + + ${header()} ${nav(data)}
    - ${data.content} + ${content}
    ${footer()} diff --git a/docs-src/_includes/relative-path.cjs b/docs-src/_includes/relative-path.cjs new file mode 100644 index 0000000..bd1d919 --- /dev/null +++ b/docs-src/_includes/relative-path.cjs @@ -0,0 +1,9 @@ +const path = require('path').posix; + +module.exports = (base, p) => { + const relativePath = path.relative(base, p); + if (p.endsWith('/') && !relativePath.endsWith('/') && relativePath !== '') { + return relativePath + '/'; + } + return relativePath; +}; diff --git a/docs/api/index.html b/docs/api/index.html index 52e1e7d..5f61fb8 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Docs - + - - + + @@ -21,7 +21,7 @@
    diff --git a/docs/examples/index.html b/docs/examples/index.html index 7a3d4fd..6a24fce 100644 --- a/docs/examples/index.html +++ b/docs/examples/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Examples ⌲ Basic - + - - + + @@ -20,7 +20,7 @@ @@ -33,11 +33,11 @@ diff --git a/docs/examples/name-property/index.html b/docs/examples/name-property/index.html index 699244a..5c844fd 100644 --- a/docs/examples/name-property/index.html +++ b/docs/examples/name-property/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Examples ⌲ Name Property - + - - + + @@ -19,10 +19,10 @@
    @@ -33,11 +33,11 @@ diff --git a/docs/index.html b/docs/index.html index 895c19c..400f29a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Home - + - - + + @@ -19,10 +19,10 @@
    diff --git a/docs/install/index.html b/docs/install/index.html index 2ebe663..efb6a8e 100644 --- a/docs/install/index.html +++ b/docs/install/index.html @@ -6,10 +6,10 @@ <my-element> ⌲ Install - + - - + + @@ -22,7 +22,7 @@ Home Examples API - Install + Install