Skip to content

Commit a1f4c16

Browse files
committed
Added --baseurloverride option.
Updated all examples to use url() properly.
1 parent 8dd7c99 commit a1f4c16

File tree

10 files changed

+24
-14
lines changed

10 files changed

+24
-14
lines changed

examples/blog/content/posts/2019/04/a-long-one.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dapibus. Massa sapien faucibus et molestie ac feugiat. Consectetur lorem donec
4444
massa sapien faucibus et molestie. Amet tellus cras adipiscing enim eu turpis
4545
egestas pretium aenean.
4646

47-
![](/images/sakura-trees.jpg)
47+
![]({{ /images/sakura-trees.jpg }})
4848

4949
Quis vel eros donec ac odio tempor orci dapibus. A cras semper auctor neque
5050
vitae tempus quam pellentesque. Amet nulla facilisi morbi tempus. Mollis nunc

examples/blog/content/posts/2019/10/it-has-been-a-while.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ page.date = "2019-10-29T17:32:00+02:00"
44
page.layout = "blogPost"
55
}}
66

7-
![](/images/sakura-trees.jpg)
7+
![]({{ /images/sakura-trees.jpg }})
88

99
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
1010
incididunt ut labore et dolore magna aliqua. Faucibus ornare suspendisse sed

examples/blog/layouts/_blogPost.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
{{ if blogPost.showSummary }}
1212
<h2>
13-
<a href="{{ blogPost.page.url }}">{{ blogPost.page.title }}</a>
13+
<a href="{{ url(blogPost.page.url) }}">{{ blogPost.page.title }}</a>
1414
</h2>
1515
<div class="body summary">
1616
{{ summarize(blogPost.page.content, 300, true) }}
1717
</div>
1818
<p>
19-
<a href="{{ blogPost.page.url }}">Continue reading</a>
19+
<a href="{{ url(blogPost.page.url) }}">Continue reading</a>
2020
</p>
2121

2222
{{ else }}

examples/blog/layouts/_header.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
</title>
1212

1313
<link rel="canonical" href="{{ url(page.permalink) }}">
14-
<link rel="stylesheet" href="{{/style.css}}">
14+
<link rel="stylesheet" href="{{ /style.css }}">
1515
</head>
1616

1717
<body>
1818
<header>
19-
<a href="/">{{ echo(site.title) }}</a>
19+
<a href="{{ / }}">{{ echo(site.title) }}</a>
2020
</header>
2121

2222
<div class="middleOuter"><div class="middleInner">
@@ -27,7 +27,7 @@ <h3>Latest Posts</h3>
2727
{{ fori subpage in subpages("/posts/") }}
2828
{{ if not subpage.isIndex }}
2929
<li>
30-
<a href="{{ subpage.url }}">
30+
<a href="{{ url(subpage.url) }}">
3131
{{ subpage.title }}<br>
3232
<span class="date">{{ os.date("%Y-%m-%d", toTime(subpage.publishDate)) }}</span>
3333
</a>

examples/portfolio/content/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
{{ echo(site.title) }}
1616
</title>
1717

18-
<link rel="canonical" href="{{ page.permalink }}">
19-
<link rel="stylesheet" href="/style.css">
18+
<link rel="canonical" href="{{ url(page.permalink) }}">
19+
<link rel="stylesheet" href="{{ /style.css }}">
2020
</head>
2121

2222
<body>
@@ -40,7 +40,7 @@ <h1>My {{ #data.art.art }} Art Pieces</h1>
4040
{{
4141
local w, h = assert(getImageDimensions(piece.file))
4242
}}
43-
<img src="{{ piece.file }}" width="{{w}}" height="{{h}}">
43+
<img src="{{ url(piece.file) }}" width="{{w}}" height="{{h}}">
4444
<div>{{ '"' .. piece.name .. '"' }}</div>
4545
</div>
4646
{{ end }}

examples/testsite/content/blog/first.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ do...end
8888
## HTML
8989

9090
<p style="text-align: center;">
91-
Centered text!
91+
Centered text in HTML. The following is not a list!
9292
- 1
9393
- 2
9494
</p>

examples/testsite/content/blog/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This is the blog index.
88
## Posts
99

1010
{{ fori page in subpages() }}
11-
- [{{ page.title }}]({{ page.url }})
11+
- [{{ page.title }}]({{ url(page.url) }})
1212
{{ end }}
1313

1414
And, that's it!

examples/testsite/content/tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ Text: {{ "foo <img>" }}
140140

141141
Html: {{ "<img>" }}
142142

143-
echo: {{ echo('<img src="/images/head.png">') }}
143+
echo: {{ echo('<img src="'..url"/images/head.png"..'">') }}
144144

145-
echoRaw: {{ echoRaw('<img src="/images/head.png">') }}
145+
echoRaw: {{ echoRaw('<img src="'..url"/images/head.png"..'">') }}
146146

147147

148148

src/app.lua2p

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ local function setup()
321321
elseif arg == "--fullpaths" then -- @Doc?
322322
_G.useFullPaths = true
323323

324+
elseif arg == "--baseurloverride" then -- @Doc?
325+
i = i + 1
326+
_G.baseUrlOverride = programArguments[i] or errorNoPos("[Arguments] Missing URL after '%s'.", argRaw)
327+
arg = arg .. '"' .. baseUrlOverride .. '"'
328+
324329
elseif arg:find"^%-" then
325330
errorNoPos("[Arguments] Unknown option '%s'.", argRaw)
326331
else
@@ -1472,6 +1477,10 @@ local function buildWebsite()
14721477
end
14731478

14741479
-- Validate config.baseUrl
1480+
if baseUrlOverride ~= "" then
1481+
site.baseUrl.v = baseUrlOverride
1482+
end
1483+
14751484
local parsedUrl = require"url".parse(site.baseUrl.v)
14761485

14771486
if site.baseUrl.v == "" then

src/globals.lua2p

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ _G.logPath = ""
6161
_G.toLog = {--[[ message1, ... ]]} -- Before the log file has opened.
6262

6363
_G.autobuild = false
64+
_G.baseUrlOverride = ""
6465
_G.enableGc = true
6566
_G.ignoreModificationTimes = false
6667
_G.includeDrafts = false

0 commit comments

Comments
 (0)