Skip to content

Commit

Permalink
Move themes static files to respective directories
Browse files Browse the repository at this point in the history
  • Loading branch information
LebCit committed Dec 25, 2023
1 parent 721324f commit e96ca4a
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 59 deletions.
2 changes: 1 addition & 1 deletion functions/search-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fetch("/static/scripts/posts.json")
// Insert the default-single-post-preview.css at the end of the head tag
document.head.insertAdjacentHTML(
"beforeend",
'<link rel="stylesheet" href="/static/styles/default-single-post-preview.css" />'
'<link rel="stylesheet" href="/static/styles/themes/default/default-single-post-preview.css" />'
)

// Define an empty string that will hold the search result(s)
Expand Down
47 changes: 0 additions & 47 deletions static/scripts/clean-blog-scripts.js

This file was deleted.

53 changes: 53 additions & 0 deletions static/scripts/themes/clean-blog/clean-blog-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
window.addEventListener("DOMContentLoaded", () => {
let scrollPos = 0
const mainNav = document.getElementById("mainNav")
const headerHeight = mainNav.clientHeight
window.addEventListener("scroll", function () {
const currentTop = document.body.getBoundingClientRect().top * -1
if (currentTop < scrollPos) {
// Scrolling Up
if (currentTop > 0 && mainNav.classList.contains("is-fixed")) {
mainNav.classList.add("is-visible")
} else {
mainNav.classList.remove("is-visible", "is-fixed")
}
} else {
// Scrolling Down
mainNav.classList.remove(["is-visible"])
if (currentTop > headerHeight && !mainNav.classList.contains("is-fixed")) {
mainNav.classList.add("is-fixed")
}
}
scrollPos = currentTop
})

// RESPONSIVE IMAGES IN PAGES AND POSTS
const main = document.getElementById("main")
// Ensure that a page or a post is displayed
if (main) {
const images = main.querySelectorAll("img")
images.forEach((image) => {
image.classList.add("img-fluid")
})
}

// Detect external links
const isExternalLink = (url) => {
const tmp = document.createElement("a")
tmp.href = url
return tmp.host !== window.location.host
}
// Select all links
const allLinks = document.querySelectorAll("a")
// Add attributes and icon to each external link
allLinks.forEach((link) => {
if (isExternalLink(link)) {
link.setAttribute("target", "_blank")
link.setAttribute("rel", "external noopener noreferrer")
link.insertAdjacentHTML(
"beforeend",
` <i class="fa-solid fa-arrow-up-right-from-square" title="External link"></i>`
)
}
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isExternalLink } from "./is-external-link.js"
import { isExternalLink } from "../../is-external-link.js"

// Utility function to ensure that the trailing slash is not considered when highlighting the menu item
function removeTrailingSlash(str) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}
.blog-card .details .date:before {
content: "";
background: url("../icons/date-post-details.svg");
background: url("../../../icons/date-post-details.svg");
position: absolute;
width: 16px;
height: 16px;
Expand All @@ -84,7 +84,7 @@
}
.blog-card .details .tags ul:before {
content: "";
background: url("../icons/tag-post-details.svg");
background: url("../../../icons/tag-post-details.svg");
position: absolute;
width: 16px;
height: 16px;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion views/posts/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Now paste the following block of code:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/purecss@3.0.0/build/grids-responsive-min.css" />
<link rel="shortcut icon" href="/icons/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/css/default-styles.min.css" />
<link rel="stylesheet" href="/static/styles/themes/default/default-styles.min.css" />
</head>
<body>
<div id="layout">
Expand Down
2 changes: 1 addition & 1 deletion views/posts/the-pagination-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The `paginated` condition is a passed data object to display or not the paginati
At the top of the `pagination.html` file, you can find a link to the stylesheet related to this component.

```xml
<link rel="stylesheet" href="/static/styles/default-pagination.css" />
<link rel="stylesheet" href="/static/styles/themes/default/default-pagination.css" />
```

Those styles will only be available when the pagination component is displayed. This is very useful to avoid loading unnecessary styles in the app.
Expand Down
2 changes: 1 addition & 1 deletion views/themes/clean-blog/components/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<%/* Bootstrap core JS */%>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<%/* Core theme JS */%>
<script src="/static/scripts/clean-blog-scripts.js"></script>
<script src="/static/scripts/themes/clean-blog/clean-blog-scripts.js"></script>
<% if (it.build) { %>
<script src="/static/scripts/search.js"></script>
<% } %> <%/*
Expand Down
2 changes: 1 addition & 1 deletion views/themes/clean-blog/components/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
type="text/css"
/>
<%/* Core theme CSS (includes Bootstrap) */%>
<link href="/static/styles/clean-blog-styles.css" rel="stylesheet" />
<link href="/static/styles/themes/clean-blog/clean-blog-styles.css" rel="stylesheet" />
<% if (it.mdRoute) { %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.8.0/styles/atom-one-dark.min.css" />
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion views/themes/default/components/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
<% } %>

<script type="module" src="/static/scripts/handle-external-links.js"></script>
<script type="module" src="/static/scripts/default-scripts.js"></script>
<script type="module" src="/static/scripts/themes/default/default-scripts.js"></script>
2 changes: 1 addition & 1 deletion views/themes/default/components/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<% /* Stylesheets*/ %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/purecss/build/pure-min.min.css" />
<link rel="stylesheet" href="/static/styles/default-styles.min.css" />
<link rel="stylesheet" href="/static/styles/themes/default/default-styles.min.css" />
<% if (it.mdRoute) { %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11.8.0/styles/atom-one-dark.min.css" />
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion views/themes/default/components/pagination.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="stylesheet" href="/static/styles/default-pagination.css" />
<link rel="stylesheet" href="/static/styles/themes/default/default-pagination.css" />
<%/*
<!-- First page pagination -->
*/%> <% if (it.firstPage && it.lastPage > 0) { %>
Expand Down
2 changes: 1 addition & 1 deletion views/themes/default/layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="stylesheet" href="/static/styles/default-single-post-preview.css" />
<link rel="stylesheet" href="/static/styles/themes/default/default-single-post-preview.css" />

<% it.posts.forEach((post, index) => { %> <%/*
<!-- Get the Markdown filename without its extension -->
Expand Down

0 comments on commit e96ca4a

Please sign in to comment.