Added site map for /articles.
This commit is contained in:
parent
b277f15e46
commit
292fa46e1b
|
@ -20,3 +20,7 @@ body {
|
|||
margin: 0 auto;
|
||||
padding: 0 0 .5rem 1rem;
|
||||
}
|
||||
|
||||
.sitemap-dir a {
|
||||
display: block;
|
||||
}
|
19
content/pages/articles.njk
Normal file
19
content/pages/articles.njk
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{% include "templates/defaultTags.njk" %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/sitemap.css">
|
||||
<title>Site Map</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
All Articles
|
||||
</header>
|
||||
<p class="centered">
|
||||
Here's a list of all articles:
|
||||
</p>
|
||||
<div class="sitemap-container">
|
||||
{{ siteMap("/articles") | safe }}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -15,14 +15,17 @@ async function handlePath(dirName, siteMap) {
|
|||
|
||||
if (fileStats.isDirectory())
|
||||
siteMap[fullPath.replace(/^[\s\S]+\/pages/, "")] = {
|
||||
path: fullPath,
|
||||
path: fullPath.replace(/^[\s\S]+\/pages/, "").replace(/\/.+\//, "/"),
|
||||
address: fullPath.replace(/^[\s\S]+\/pages/, ""),
|
||||
type: "directory",
|
||||
children: await handlePath(fullPath, {})
|
||||
}
|
||||
else
|
||||
// Check if it already exists
|
||||
siteMap[fullPath.replace(/^[\s\S]+\/pages/, "").replace(/\.[a-z]+$/, "")] ?
|
||||
siteMap[fullPath.replace(/^[\s\S]+\/pages/, "").replace(/\.[a-z]+$/, "")] :
|
||||
siteMap[fullPath.replace(/^[\s\S]+\/pages/, "").replace(/\.[a-z]+$/, "")] = {
|
||||
path: fullPath,
|
||||
path: fullPath.replace(/^[\s\S]+\/pages/, "").replace(/\.[a-z]+$/, "").replace(/\/.+\//, "/"),
|
||||
address: fullPath.replace(/^[\s\S]+\/pages/, "").replace(/\.[a-z]+$/, ""),
|
||||
type: "file"
|
||||
}
|
||||
|
@ -45,11 +48,11 @@ function renderSiteMap(siteMap, entrypoint) {
|
|||
continue
|
||||
|
||||
if (dir.type === "directory") {
|
||||
result.push(`<a href="${dir.address}">${dir.address}`)
|
||||
result.push(`<a href="${dir.address}">${dir.path}`)
|
||||
result.push(renderSiteMap(dir.children, entrypoint))
|
||||
result.push(`</a>`)
|
||||
} else {
|
||||
result.push(`<a href="${dir.address}">${dir.address}</a>`)
|
||||
result.push(`<a href="${dir.address}">${dir.path}</a>`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user