Skip to content

Commit

Permalink
Disable pretty links for loose MD.
Browse files Browse the repository at this point in the history
Better to do them in place, so they can reference static files relatively correctly.
  • Loading branch information
bcomnes committed Sep 5, 2021
1 parent 659b672 commit 686b9e5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/build-pages/page-builders/md/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export async function mdBuilder ({ page }) {
* @param {Boolean} pretty - rewrite links for pretty URLs (directory indexes)
* @return {String}
*/
function rewriteLinks (body, pretty) {
function rewriteLinks (body /*, pretty */) {
body = body || ''

if (pretty !== false) pretty = true // default to true if omitted
// if (pretty !== false) pretty = true // default to true if omitted

const regex = /(href=")((?!http[s]*:).*)(\.md|\.markdown)"/g

Expand All @@ -83,7 +83,7 @@ function rewriteLinks (body, pretty) {
if (f.match(/readme$/)) return p1 + f.replace(/readme$/, '') + '"'

// pretty url
if (pretty) return p1 + f + '/"'
// if (pretty) return p1 + f + '/"'

// default
return p1 + f + '.html"'
Expand Down
2 changes: 2 additions & 0 deletions test-project/public/md-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<h1>Hello Title</h1>
<p>This is a markdown page</p>
<p>Testing watching</p>
<p>This is a link to another <a href="./loose-md-page.html">md</a> doc.</p>
<p>This is a link to a <a href="../md-two/">readme MD</a></p>
</body>

</html>
17 changes: 17 additions & 0 deletions test-project/public/md-two/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>test-project | MD Two</title>
<meta name="viewport" content="width=device-width, user-scalable=no" />
<script src="/global.client.js" type='module'></script>
<link rel="stylesheet" href="/global.css" />
</head>

<body>
<h1>MD Two</h1>
<p>Here is another readme</p>
</body>

</html>
6 changes: 6 additions & 0 deletions test-project/src/md-page/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ array:
This is a markdown page

Testing watching


This is a link to another [md](./loose-md-page.md) doc.


This is a link to a [readme MD](../md-two/README.md)
3 changes: 3 additions & 0 deletions test-project/src/md-two/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# MD Two

Here is another readme

0 comments on commit 686b9e5

Please sign in to comment.