diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index fb615c8..a222d4e 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: ['https://www.buymeacoffee.com/jimmycai'] \ No newline at end of file +ko_fi: jimmycai \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index fcca4ea..6e57d9b 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,31 +1,33 @@ -name-template: 'v$RESOLVED_VERSION 🌈' -tag-template: 'v$RESOLVED_VERSION' +name-template: "v$RESOLVED_VERSION 🌈" +tag-template: "v$RESOLVED_VERSION" categories: - - title: '🚀 Features' - labels: - - 'feature' - - 'enhancement' - - title: '🐛 Bug Fixes' - labels: - - 'fix' - - 'bugfix' - - 'bug' - - title: '🧰 Maintenance' - label: 'chore' -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' + - title: "🚀 Features" + labels: + - "feature" + - "enhancement" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - title: "🧰 Maintenance" + label: "chore" + - title: "♻️ Refactor" + label: refactor +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: - major: - labels: - - 'major' - minor: - labels: - - 'minor' - patch: - labels: - - 'patch' - default: patch + major: + labels: + - "major" + minor: + labels: + - "minor" + patch: + labels: + - "patch" + default: patch template: | - ## Changes + ## Changes - $CHANGES + $CHANGES diff --git a/README.md b/README.md index e871020..c16389d 100644 --- a/README.md +++ b/README.md @@ -20,22 +20,19 @@ Stack is a simple card-style Hugo theme designed for bloggers, some of its featu - Responsive images support - Lazy load images - Dark mode +- Local search - [PhotoSwipe](https://photoswipe.com/) integration - Archive page template - Full native JavaScript, no jQuery or any other frameworks are used - No CSS framework, keep it simple and minimal -- External dependencies (like PhotoSwipe's library) are being loaded selectively, or asynchronously - Properly cropped thumbnails - -The only JavaScript library being used is [node-vibrant](https://github.com/Vibrant-Colors/node-vibrant) for generating colour schemes for articles. - -![Page Insight](https://i.imgur.com/0hUWmMh.png) +- Subsection support ## Requirements -This theme uses SCSS and TypeScript. For that reason, it's necessary to use **Hugo ≥ 0.74.0**. +It's necessary to use **Hugo ≥ 0.78.0**. -Use Hugo Extended version if you want to: +Use Hugo Extended version (recommended) if you want to: * Use the latest feature/fix from `master` branch * Edit SCSS files @@ -46,7 +43,7 @@ Use Hugo Extended version if you want to: Clone / Download this repository to `theme` folder, and edit your site config following `exampleSite/config.toml`. -Check [documentation](https://www.notion.so/jimmycai/Hugo-Theme-Stack-511aec5b9ed845ce9b6e3ae0bf7fb6d4) for more details. +Check [documentation](https://docs.stack.jimmycai.com/) for more details. ## Copyright @@ -58,9 +55,9 @@ If you want to port this theme to another blogging platform, please let me know ## Sponsoring -If you like this theme, consider supporting its development: +If you like this theme, give it a star, and consider supporting its development: -Buy Me A Coffee +[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/C0C530AXX) Your support is greatly appreciated :) diff --git a/assets/icons/toggle-left.svg b/assets/icons/toggle-left.svg new file mode 100644 index 0000000..c3048d4 --- /dev/null +++ b/assets/icons/toggle-left.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/icons/toggle-right.svg b/assets/icons/toggle-right.svg new file mode 100644 index 0000000..d3edd63 --- /dev/null +++ b/assets/icons/toggle-right.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/jsconfig.json b/assets/jsconfig.json new file mode 100644 index 0000000..9321136 --- /dev/null +++ b/assets/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "*": [ + "*" + ] + }, + } +} \ No newline at end of file diff --git a/assets/scss/grid.scss b/assets/scss/grid.scss index 73fcdfc..f36ed34 100644 --- a/assets/scss/grid.scss +++ b/assets/scss/grid.scss @@ -112,8 +112,6 @@ main.main { padding-top: var(--main-top-padding); } -.main-grid { - @media (max-width: $on-phone) { - flex-direction: column; - } -} +.main-container { + min-height: 100vh; +} \ No newline at end of file diff --git a/assets/scss/partials/article.scss b/assets/scss/partials/article.scss index 1f40673..2c42ec7 100644 --- a/assets/scss/partials/article.scss +++ b/assets/scss/partials/article.scss @@ -56,24 +56,6 @@ padding: var(--card-padding); } -.article-category { - margin-bottom: 10px; - a { - display: inline-block; - text-decoration: none; - padding: 8px 16px; - font-size: 1.4rem; - background: nth($defaultTagBackgrounds, 1); - color: nth($defaultTagColors, 1); - border-radius: var(--tag-border-radius); - - @media (max-width: $on-phone) { - font-size: 1.25rem; - padding: 8px 14px; - } - } -} - .article-title { font-weight: 600; margin: 10px 0; @@ -128,11 +110,12 @@ } } +.article-category, .article-tags { a { color: var(--accent-color-text); background-color: var(--accent-color); - padding: 8px 18px; + padding: 8px 16px; border-radius: var(--tag-border-radius); display: inline-block; font-size: 1.4rem; @@ -193,6 +176,7 @@ img { width: var(--image-size); height: var(--image-size); + object-fit: cover; } } @@ -200,7 +184,7 @@ font-size: 1.4rem; } - .article-preview{ + .article-preview { font-size: 1.4rem; color: var(--card-text-color-tertiary); margin-top: 10px; diff --git a/assets/css/highlight/dark.css b/assets/scss/partials/highlight/dark.scss similarity index 98% rename from assets/css/highlight/dark.css rename to assets/scss/partials/highlight/dark.scss index 7f5b872..00e8942 100644 --- a/assets/css/highlight/dark.css +++ b/assets/scss/partials/highlight/dark.scss @@ -3,11 +3,6 @@ * https://xyproto.github.io/splash/docs/monokai.html */ -:root { - --pre-text-color: #f8f8f2; - --pre-background-color: #272822; -} - /* Background */ .chroma { color: #f8f8f2; diff --git a/assets/css/highlight/light.css b/assets/scss/partials/highlight/light.scss similarity index 98% rename from assets/css/highlight/light.css rename to assets/scss/partials/highlight/light.scss index 9c4e0da..7ac7d71 100644 --- a/assets/css/highlight/light.css +++ b/assets/scss/partials/highlight/light.scss @@ -2,10 +2,6 @@ * Style: monokailight * https://xyproto.github.io/splash/docs/monokailight.html */ -:root { - --pre-text-color: #272822; - --pre-background-color: #fafafa; -} /* Background */ .chroma { diff --git a/assets/scss/partials/layout/archives.scss b/assets/scss/partials/layout/archives.scss index 2ac3836..34e5f62 100644 --- a/assets/scss/partials/layout/archives.scss +++ b/assets/scss/partials/layout/archives.scss @@ -1,31 +1,3 @@ .archives-group { margin-bottom: var(--section-separation); -} - -.template-archives { - .category-list { - margin-bottom: var(--section-separation); - overflow-x: auto; - - .article-list--tile { - display: flex; - padding-bottom: 15px; - - article { - width: 250px; - height: 150px; - margin-right: 20px; - flex-shrink: 0; - - .article-title { - margin: 0; - font-size: 1.8rem; - } - - .article-details { - padding: 20px; - } - } - } - } -} +} \ No newline at end of file diff --git a/assets/scss/partials/layout/article.scss b/assets/scss/partials/layout/article.scss index c76fcce..4b3beca 100644 --- a/assets/scss/partials/layout/article.scss +++ b/assets/scss/partials/layout/article.scss @@ -305,4 +305,8 @@ tr:nth-child(even) { background-color: var(--tr-even-background-color); } + + .twitter-tweet { + color: var(--card-text-color-main); + } } diff --git a/assets/scss/partials/layout/taxonomy.scss b/assets/scss/partials/layout/list.scss similarity index 57% rename from assets/scss/partials/layout/taxonomy.scss rename to assets/scss/partials/layout/list.scss index 4575a20..1a0e346 100644 --- a/assets/scss/partials/layout/taxonomy.scss +++ b/assets/scss/partials/layout/list.scss @@ -1,4 +1,4 @@ -.taxonomy-card { +.section-card { border-radius: var(--card-border-radius); background-color: var(--card-background); padding: var(--small-card-padding); @@ -9,37 +9,37 @@ --separation: 15px; - .taxonomy-term { + .section-term { font-size: 2.2rem; margin: 0; margin-top: calc(var(--separation) / 2); color: var(--card-text-color-main); - & + .taxonomy-description { + & + .section-description { margin-top: var(--separation); } } - .taxonomy-description { + .section-description { font-weight: normal; color: var(--card-text-color-secondary); font-size: 1.6rem; margin: 0; } - .taxonomy-details { + .section-details { flex-grow: 1; margin-right: 20px; } - .taxonomy-image { + .section-image { img { width: 60px; height: 60px; } } - .taxonomy-count { + .section-count { color: var(--card-text-color-tertiary); font-size: 1.4rem; margin: 0; @@ -47,3 +47,29 @@ text-transform: uppercase; } } + +.subsection-list { + margin-bottom: var(--section-separation); + overflow-x: auto; + + .article-list--tile { + display: flex; + padding-bottom: 15px; + + article { + width: 250px; + height: 150px; + margin-right: 20px; + flex-shrink: 0; + + .article-title { + margin: 0; + font-size: 1.8rem; + } + + .article-details { + padding: 20px; + } + } + } +} diff --git a/assets/scss/partials/menu.scss b/assets/scss/partials/menu.scss index 5cefeb3..024b3a6 100644 --- a/assets/scss/partials/menu.scss +++ b/assets/scss/partials/menu.scss @@ -129,6 +129,8 @@ margin-top: var(--sidebar-element-separation); margin-bottom: 0; overflow-y: auto; + flex-grow: 1; + font-size: 1.5rem; @media (min-width: $on-desktop-large) { margin-top: 30px; @@ -192,7 +194,6 @@ display: inline-flex; align-items: center; color: var(--body-text-color); - font-size: 1.5rem; @media (max-width: $on-desktop-large) { font-size: 1.4rem; diff --git a/assets/scss/partials/sidebar.scss b/assets/scss/partials/sidebar.scss index 8eddafc..b6722a9 100644 --- a/assets/scss/partials/sidebar.scss +++ b/assets/scss/partials/sidebar.scss @@ -134,3 +134,30 @@ } } } + +[data-scheme="dark"] { + #dark-mode-toggle { + color: var(--accent-color); + font-weight: 700; + + .icon-tabler-toggle-left { + display: none; + } + + .icon-tabler-toggle-right { + display: unset; + } + } +} + +#dark-mode-toggle { + margin-top: auto; + color: var(--body-text-color); + display: flex; + align-items: center; + cursor: pointer; + + .icon-tabler-toggle-right { + display: none; + } +} diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 3e4b56a..2f5aac9 100644 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -21,7 +21,7 @@ @import "partials/base.scss"; @import "partials/layout/archives.scss"; @import "partials/layout/article.scss"; -@import "partials/layout/taxonomy.scss"; +@import "partials/layout/list.scss"; @import "partials/layout/404.scss"; @import "partials/layout/search.scss"; diff --git a/assets/scss/variables.scss b/assets/scss/variables.scss index 14d9e07..3a8a1a5 100644 --- a/assets/scss/variables.scss +++ b/assets/scss/variables.scss @@ -1,6 +1,18 @@ $defaultTagBackgrounds: #8ea885, #df7988, #0177b8, #ffb900, #6b69d6; $defaultTagColors: #fff, #fff, #fff, #fff, #fff; +[data-scheme="light"] { + --pre-text-color: #272822; + --pre-background-color: #fafafa; + @import "partials/highlight/light.scss"; +} + +[data-scheme="dark"] { + --pre-text-color: #f8f8f2; + --pre-background-color: #272822; + @import "partials/highlight/dark.scss"; +} + /* * Global style */ @@ -13,7 +25,6 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff; --main-top-padding: 50px; } - --body-background: #f5f5fa; --accent-color: #34495e; @@ -25,7 +36,7 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff; --section-separation: 40px; - @media (prefers-color-scheme: dark) { + [data-scheme="dark"] { --body-background: #303030; --accent-color: #ecf0f1; --accent-color-darker: #bdc3c7; @@ -72,7 +83,7 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff; --small-card-padding: 25px 20px; } - @media (prefers-color-scheme: dark) { + [data-scheme="dark"] { --card-background: #424242; --card-background-selected: rgba(255, 255, 255, 0.16); --card-text-color-main: rgba(255, 255, 255, 0.9); @@ -116,7 +127,7 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff; --table-border-color: #dadada; --tr-even-background-color: #efefee; - @media (prefers-color-scheme: dark) { + [data-scheme="dark"] { --code-background-color: #272822; --code-text-color: rgba(255, 255, 255, 0.9); diff --git a/assets/ts/colorScheme.ts b/assets/ts/colorScheme.ts new file mode 100644 index 0000000..e17ff07 --- /dev/null +++ b/assets/ts/colorScheme.ts @@ -0,0 +1,86 @@ +type colorScheme = 'light' | 'dark' | 'auto'; + +class StackColorScheme { + private localStorageKey = 'StackColorScheme'; + private currentScheme: colorScheme; + private systemPreferScheme: colorScheme; + + constructor(toggleEl: HTMLElement) { + this.bindMatchMedia(); + this.currentScheme = this.getSavedScheme(); + + if (toggleEl) + this.bindClick(toggleEl); + + if (document.body.style.transition == '') + document.body.style.setProperty('transition', 'background-color .3s ease'); + } + + private saveScheme() { + localStorage.setItem(this.localStorageKey, this.currentScheme); + } + + private bindClick(toggleEl) { + toggleEl.addEventListener('click', (e) => { + if (this.isDark()) { + /// Disable dark mode + this.currentScheme = 'light'; + } + else { + this.currentScheme = 'dark'; + } + + this.setBodyClass(); + + if (this.currentScheme == this.systemPreferScheme) { + /// Set to auto + this.currentScheme = 'auto'; + } + + this.saveScheme(); + }) + } + + private isDark() { + return (this.currentScheme == 'dark' || this.currentScheme == 'auto' && this.systemPreferScheme == 'dark'); + } + + private dispatchEvent(colorScheme: colorScheme) { + const event = new CustomEvent('onColorSchemeChange', { + detail: colorScheme + }); + window.dispatchEvent(event); + } + + private setBodyClass() { + if (this.isDark()) { + document.body.dataset.scheme = 'dark'; + } + else { + document.body.dataset.scheme = 'light'; + } + + this.dispatchEvent(document.body.dataset.scheme as colorScheme); + } + + private getSavedScheme(): colorScheme { + const savedScheme = localStorage.getItem(this.localStorageKey); + + if (savedScheme == 'light' || savedScheme == 'dark' || savedScheme == 'auto') return savedScheme; + else return 'auto'; + } + + private bindMatchMedia() { + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => { + if (e.matches) { + this.systemPreferScheme = 'dark'; + } + else { + this.systemPreferScheme = 'light'; + } + this.setBodyClass(); + }); + } +} + +export default StackColorScheme; \ No newline at end of file diff --git a/assets/ts/gallery.ts b/assets/ts/gallery.ts index 41fba8e..8bce5a9 100644 --- a/assets/ts/gallery.ts +++ b/assets/ts/gallery.ts @@ -1,287 +1,132 @@ -import { loadScript, loadStyle } from './utils'; +declare global { + interface Window { + PhotoSwipe: any; + PhotoSwipeUI_Default: any + } +} -/** - * Init PhotoSwipe - * From: https://photoswipe.com/documentation/getting-started.html - * @param gallerySelector - */ -var initPhotoSwipeFromDOM = function (gallerySelector) { +interface PhotoSwipeItem { + w: number; + h: number; + src: string; + msrc: string; + title?: string; + el: HTMLElement; +} - // parse slide data (url, title, size ...) from DOM elements - // (children of gallerySelector) - var parseThumbnailElements = function (el) { - var thumbElements = el.childNodes, - numNodes = thumbElements.length, - items = [], - figureEl, - linkEl, - size, - item; +class StackGallery { + private galleryUID: number; + private items: PhotoSwipeItem[] = []; - for (var i = 0; i < numNodes; i++) { - - figureEl = thumbElements[i]; //
element - - // include only element nodes - if (figureEl.nodeType !== 1) { - continue; - } - - linkEl = figureEl.children[0]; // element - - size = linkEl.getAttribute('data-size').split('x'); - - // create slide object - item = { - src: linkEl.getAttribute('href'), - w: parseInt(size[0], 10), - h: parseInt(size[1], 10) - }; - - - - if (figureEl.children.length > 1) { - //
content - item.title = figureEl.children[1].innerHTML; - } - - if (linkEl.children.length > 0) { - // thumbnail element, retrieving thumbnail url - item.msrc = linkEl.children[0].getAttribute('src'); - } - - item.el = figureEl; // save link to element for getThumbBoundsFn - items.push(item); - } - - return items; - }; - - // find nearest parent element - var closest = function closest(el, fn) { - return el && (fn(el) ? el : closest(el.parentNode, fn)); - }; - - // triggers when user clicks on thumbnail - var onThumbnailsClick = function (e) { - e = e || window.event; - e.preventDefault ? e.preventDefault() : e.returnValue = false; - - var eTarget = e.target || e.srcElement; - - // find root element of slide - var clickedListItem = closest(eTarget, function (el) { - return (el.tagName && el.tagName.toUpperCase() === 'FIGURE'); - }); - - if (!clickedListItem) { + constructor(container: HTMLElement, galleryUID = 1) { + if (window.PhotoSwipe == undefined || window.PhotoSwipeUI_Default == undefined) { + console.error("PhotoSwipe lib not loaded."); return; } - // find index of clicked item by looping through all child nodes - // alternatively, you may define index via data- attribute - var clickedGallery = clickedListItem.parentNode, - childNodes = clickedListItem.parentNode.childNodes, - numChildNodes = childNodes.length, - nodeIndex = 0, - index; + this.galleryUID = galleryUID; - for (var i = 0; i < numChildNodes; i++) { - if (childNodes[i].nodeType !== 1) { - continue; + StackGallery.createGallery(container); + this.loadItems(container); + this.bindClick(); + } + + private loadItems(container: HTMLElement) { + this.items = []; + + const figures = container.querySelectorAll('figure'); + + for (const el of figures) { + const figcaption = el.querySelector('figcaption'), + img = el.querySelector('img'); + + let aux: PhotoSwipeItem = { + w: parseInt(img.getAttribute('width')), + h: parseInt(img.getAttribute('height')), + src: img.src, + msrc: img.getAttribute('data-thumb') || img.src, + el: el } - if (childNodes[i] === clickedListItem) { - index = nodeIndex; - break; + if (figcaption) { + aux.title = figcaption.innerHTML; } - nodeIndex++; + + this.items.push(aux); } + } - if (index >= 0) { - // open PhotoSwipe if valid index found - openPhotoSwipe(index, clickedGallery); - } - return false; - }; + public static createGallery(container: HTMLElement) { + const figuresEl = container.querySelectorAll('figure'); - // parse picture index and gallery index from URL (#&pid=1&gid=2) - var photoswipeParseHash = function () { - var hash = window.location.hash.substring(1), - params = {}; + let currentGallery = []; - if (hash.length < 5) { - return params; - } - - var vars = hash.split('&'); - for (var i = 0; i < vars.length; i++) { - if (!vars[i]) { - continue; + for (const figure of figuresEl) { + if (!currentGallery.length) { + /// First iteration + currentGallery = [figure]; } - var pair = vars[i].split('='); - if (pair.length < 2) { - continue; + else if (figure.previousElementSibling === currentGallery[currentGallery.length - 1]) { + /// Adjacent figures + currentGallery.push(figure); + } + else if (currentGallery.length) { + /// End gallery + StackGallery.wrap(currentGallery); + currentGallery = [figure]; } - params[pair[0]] = pair[1]; } - if (params.gid) { - params.gid = parseInt(params.gid, 10); + if (currentGallery.length > 0) { + StackGallery.wrap(currentGallery); } + } - return params; - }; + /** + * Wrap adjacent figure tags with div.gallery + * @param figures + */ + public static wrap(figures: HTMLElement[]) { + const galleryContainer = document.createElement('div'); + galleryContainer.className = 'gallery'; - var openPhotoSwipe = function (index, galleryElement, disableAnimation, fromURL) { - var pswpElement = document.querySelectorAll('.pswp')[0], - gallery, - options, - items; + const parentNode = figures[0].parentNode, + first = figures[0]; - items = parseThumbnailElements(galleryElement); + parentNode.insertBefore(galleryContainer, first) - // define options (if needed) - options = { + for (const figure of figures) { + galleryContainer.appendChild(figure); + } + } - // define gallery index (for URL) - galleryUID: galleryElement.getAttribute('data-pswp-uid'), - - getThumbBoundsFn: function (index) { - // See Options -> getThumbBoundsFn section of documentation for more info - var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail + public open(index: number) { + const pswp = document.querySelector('.pswp') as HTMLDivElement; + const ps = new window.PhotoSwipe(pswp, window.PhotoSwipeUI_Default, this.items, { + index: index, + galleryUID: this.galleryUID, + getThumbBoundsFn: (index) => { + const thumbnail = this.items[index].el.getElementsByTagName('img')[0], pageYScroll = window.pageYOffset || document.documentElement.scrollTop, rect = thumbnail.getBoundingClientRect(); return { x: rect.left, y: rect.top + pageYScroll, w: rect.width }; } + }); - }; - - // PhotoSwipe opened from URL - if (fromURL) { - if (options.galleryPIDs) { - // parse real index when custom PIDs are used - // http://photoswipe.com/documentation/faq.html#custom-pid-in-url - for (var j = 0; j < items.length; j++) { - if (items[j].pid == index) { - options.index = j; - break; - } - } - } else { - // in URL indexes start from 1 - options.index = parseInt(index, 10) - 1; - } - } else { - options.index = parseInt(index, 10); - } - - // exit if index not found - if (isNaN(options.index)) { - return; - } - - if (disableAnimation) { - options.showAnimationDuration = 0; - } - - // Pass data to PhotoSwipe and initialize it - gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); - gallery.init(); - }; - - // loop through all gallery elements and bind events - var galleryElements = document.querySelectorAll(gallerySelector); - - for (var i = 0, l = galleryElements.length; i < l; i++) { - galleryElements[i].setAttribute('data-pswp-uid', i + 1); - galleryElements[i].onclick = onThumbnailsClick; + ps.init(); } - // Parse URL and open gallery if it contains #&pid=3&gid=1 - var hashData = photoswipeParseHash(); - if (hashData.pid && hashData.gid) { - openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true); - } -}; + private bindClick() { + for (const [index, item] of this.items.entries()) { + const a = item.el.querySelector('a'); -/** - * Wrap adjacent figure tags with div.gallery, and append style - * Reference: https://github.com/xieranmaya/blog/issues/6 - * @param gallery - */ -function wrap(gallery: HTMLElement[]) { - let galleryContainer = document.createElement('div'); - galleryContainer.className = 'gallery'; - - let parentNode = gallery[0].parentNode, - first = gallery[0]; - - parentNode.insertBefore(galleryContainer, first) - - for (let j = 0; j < gallery.length; ++j) { - const width = gallery[j].querySelector('img').width, - height = gallery[j].querySelector('img').height; - - gallery[j].style.flexGrow = `${width * 100 / height}`; - gallery[j].style.flexBasis = `${width * 240 / height}px`; - - galleryContainer.appendChild(gallery[j]); + a.addEventListener('click', (e) => { + e.preventDefault(); + this.open(index); + }) + } } } -/** - * Load PhotoSwipe library dynamically - */ -function loadPhotoSwipe() { - const tasks = [ - loadScript("https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"), - loadScript("https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"), - loadStyle("https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css"), - loadStyle("https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css") - ]; - - return Promise.all(tasks); -} - -/** - * Create gallery - * @param selector - */ -function createGallery(selector: string) { - const figures = document.querySelector(selector).querySelectorAll('figure'); - - if (figures.length) { - let currentGallery = [figures[0]]; - for (let i = 1; i < figures.length; ++i) { - if (figures[i].previousElementSibling === currentGallery[currentGallery.length - 1]) { - /* Adjacent */ - currentGallery.push(figures[i]); - } - else { - /* End gallery */ - wrap(currentGallery); - currentGallery = [figures[i]]; - } - } - - if (currentGallery.length > 0) { - wrap(currentGallery); - } - - /** - * Load PhotoSwipe library, and then initialize - */ - loadPhotoSwipe().then(() => { - const pswp = document.querySelector('.pswp') as HTMLDivElement; - pswp.style.removeProperty('display'); - - initPhotoSwipeFromDOM(`${selector} .gallery`); - }) - } -} - -export { - createGallery -} \ No newline at end of file +export default StackGallery; \ No newline at end of file diff --git a/assets/ts/main.ts b/assets/ts/main.ts index 8875a74..2fcc152 100644 --- a/assets/ts/main.ts +++ b/assets/ts/main.ts @@ -5,11 +5,11 @@ * @website: https://jimmycai.com * @link: https://github.com/CaiJimmy/hugo-theme-stack */ - -import { createGallery } from "./gallery" -import { getColor } from './color'; -import menu from './menu'; -import createElement from './createElement'; +import StackGallery from "ts/gallery"; +import { getColor } from 'ts/color'; +import menu from 'ts/menu'; +import createElement from 'ts/createElement'; +import StackColorScheme from 'ts/colorScheme'; let Stack = { init: () => { @@ -18,24 +18,11 @@ let Stack = { */ menu(); - if (document.querySelector('.article-content')) { - createGallery('.article-content'); + const articleContent = document.querySelector('.article-content') as HTMLElement; + if (articleContent) { + new StackGallery(articleContent); } - /** - * Add color to tags - */ - document.querySelectorAll('.color-tag').forEach(async (tag: HTMLLinkElement) => { - const imageURL = tag.getAttribute('data-image'), - key = tag.getAttribute('data-key'), - hash = tag.getAttribute('data-hash'); - - const colors = await getColor(key, hash, imageURL); - - tag.style.color = colors.Vibrant.bodyTextColor; - tag.style.background = colors.Vibrant.hex; - }) - /** * Add linear gradient background to tile style article */ @@ -66,6 +53,8 @@ let Stack = { observer.observe(articleTile) } + + new StackColorScheme(document.getElementById('dark-mode-toggle')); } } diff --git a/assets/ts/utils.ts b/assets/ts/utils.ts deleted file mode 100644 index f725ca3..0000000 --- a/assets/ts/utils.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Load script asynchronous - * @return {Promise} - * @param url - */ -const loadScript = function (url) { - return new Promise(resolve => { - var scriptTag = document.createElement('script'); - scriptTag.src = url; - - scriptTag.onload = () => { - resolve(); - }; - - document.head.appendChild(scriptTag); - }) -}; - -/** - * Load style asynchronous - * @return {Promise} - * @param url - */ -const loadStyle = function (url) { - return new Promise(resolve => { - var link = document.createElement('link'); - link.href = url; - - link.type = "text/css"; - link.rel = "stylesheet"; - - link.onload = () => { - resolve(); - }; - - document.head.appendChild(link); - }); -}; - -export { - loadScript, - loadStyle -} \ No newline at end of file diff --git a/exampleSite/config.toml b/exampleSite/config.toml deleted file mode 100644 index 3134043..0000000 --- a/exampleSite/config.toml +++ /dev/null @@ -1,103 +0,0 @@ -baseurl = "https://example.com" -languageCode = "en-us" -theme = "hugo-theme-stack" -paginate = 5 -title = "Example Site" -disqusShortname = "hugo-theme-stack" # Change it to your Disqus shortname before using -DefaultContentLanguage = "en" # Theme i18n support - -[permalinks] - post = "/p/:slug/" - page = "/:slug/" - -[params] - mainSections = ["post"] - featuredImageField = "image" - rssFullContent = true - - [params.dateFormat] - published = "Jan 02, 2006" - lastUpdated = "Jan 02, 2006 15:04 MST" - - [params.sidebar] - emoji = "🍥" - avatar = "img/avatar.png" - subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." - - [params.article] - math = false - [params.article.license] - enabled = true - default = "Licensed under CC BY-NC-SA 4.0" - - [params.comments] - enabled = true - provider = "disqus" # Available: disqus, utterances - [params.comments.utterances] - repo = "" - issueTerm = "pathname" - label = "" # Optional - theme = "preferred-color-scheme" - - [params.widgets] - enabled = ['search', 'archives', 'tag-cloud'] - [params.widgets.archives] - limit = 5 - ### Archives page relative URL - path = "archives" - [params.widgets.tagCloud] - limit = 10 - - [params.opengraph] - [params.opengraph.twitter] - site = "" - card = "summary_large_image" - - [params.defaultImage] - [params.defaultImage.opengraph] - enabled = false - local = false - src = "" - -[menu] - [[menu.main]] - identifier = "home" - name = "Home" - url = "/" - weight = -100 - pre = "home" - [[menu.main]] - identifier = "about-cn" - name = "About" - url = "about" - weight = -90 - pre = "user" - [[menu.main]] - identifier = "archives" - name = "Archives" - url = "archives" - weight = -70 - pre = "archives" - [[menu.main]] - identifier = "search" - name = "Search" - url = "search" - weight = -60 - pre = "search" - -[related] - includeNewer = true - threshold = 60 - toLower = false - - [[related.indices]] - name = "tags" - weight = 100 - - [[related.indices]] - name = "categories" - weight = 200 - -[markup] - [markup.highlight] - noClasses = false diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml new file mode 100644 index 0000000..a0266c8 --- /dev/null +++ b/exampleSite/config.yaml @@ -0,0 +1,134 @@ +baseurl: https://example.com +languageCode: en-us +theme: hugo-theme-stack +paginate: 5 +title: Example Site + +# Change it to your Disqus shortname before using +disqusShortname: hugo-theme-stack + +# Theme i18n support +# Available values: en, fr, id, ja, ko, pt-br, zh-cn +DefaultContentLanguage: en + +permalinks: + post: /p/:slug/ + page: /:slug/ + +params: + mainSections: + - post + featuredImageField: image + rssFullContent: true + favicon: + + footer: + since: 2020 + customText: + + dateFormat: + published: Jan 02, 2006 + lastUpdated: Jan 02, 2006 15:04 MST + + sidebar: + emoji: 🍥 + subtitle: Lorem ipsum dolor sit amet, consectetur adipiscing elit. + avatar: + local: true + src: img/avatar.png + + article: + math: false + license: + enabled: true + default: Licensed under CC BY-NC-SA 4.0 + + comments: + enabled: true + provider: disqus + utterances: + repo: + issueTerm: pathname + label: + theme: preferred-color-scheme + + widgets: + enabled: + - search + - archives + - tag-cloud + + archives: + limit: 5 + path: archives + + tagCloud: + limit: 10 + + opengraph: + twitter: + # Your Twitter username + site: + + # Available values: summary, summary_large_image + card: summary_large_image + + defaultImage: + opengraph: + enabled: false + local: false + src: + + colorScheme: + # Display toggle + toggle: true + + # Available values: auto, light, dark + default: auto + + imageProcessing: + cover: + enabled: true + content: + enabled: true + +menu: + main: + - identifier: home + name: Home + url: / + weight: -100 + pre: home + + - identifier: about + name: About + url: about + weight: -90 + pre: user + + - identifier: archives + name: Archives + url: archives + weight: -70 + pre: archives + + - identifier: search + name: Search + url: search + weight: -60 + pre: search + +related: + includeNewer: true + threshold: 60 + toLower: false + indices: + - name: tags + weight: 100 + + - name: categories + weight: 200 + +markup: + highlight: + noClasses: false diff --git a/exampleSite/content/categories/Test/_index.md b/exampleSite/content/categories/Test/_index.md index 547b3b7..0b3cfa9 100644 --- a/exampleSite/content/categories/Test/_index.md +++ b/exampleSite/content/categories/Test/_index.md @@ -3,4 +3,7 @@ title: "Test" description: "This is a example category" slug: "test" image: "hutomo-abrianto-l2jk-uxb1BY-unsplash.jpg" +style: + background: "#2a9d8f" + color: "#fff" --- \ No newline at end of file diff --git a/i18n/en.toml b/i18n/en.toml deleted file mode 100644 index 1261a18..0000000 --- a/i18n/en.toml +++ /dev/null @@ -1,41 +0,0 @@ -[toggleMenu] - other = "Toggle Menu" - -[relatedContents] - other = "Related contents" - -[lastUpdatedOn] - other ="Last updated on" - -[widgetArchivesTitle] - other = "Archives" - -[widgetArchivesMore] - other = "More" - -[widgetTagCloudTitle] - other = "Tags" - -[categoriesTitle] - other = "Categories" - -[notFoundTitle] - other = "Not Found" - -[notFoundSubtitle] - other = "This page does not exist." - -[searchTitle] - other = "Search" - -[searchPlaceholder] - other = "Type something..." - -[searchResultTitle] - other = "#PAGES_COUNT pages (#TIME_SECONDS seconds)" - -[footerBuiltWith] - other = "Built with {{ .Generator }}" - -[footerDesignedBy] - other = "Theme {{ .Theme }} designed by {{ .DesignedBy }}" diff --git a/i18n/en.yaml b/i18n/en.yaml new file mode 100644 index 0000000..e131b61 --- /dev/null +++ b/i18n/en.yaml @@ -0,0 +1,57 @@ +toggleMenu: + other: Toggle Menu + +darkMode: + other: Dark Mode + +list: + page: + one: "{{ .Count }} page" + other: "{{ .Count }} pages" + + section: + other: Section + + subsection: + one: Subsection + other: Subsections + +archives: + categories: + other: Categories + +article: + relatedContents: + other: Related contents + lastUpdatedOn: + other: Last updated on + +notFound: + title: + other: Not Found + subtitle: + other: This page does not exist. + +widget: + archives: + title: + other: Archives + more: + other: More + tagCloud: + title: + other: Tags + +search: + title: + other: Search + placeholder: + other: Type something... + resultTitle: + other: "#PAGES_COUNT pages (#TIME_SECONDS seconds)" + +footer: + builtWith: + other: Built with {{ .Generator }} + designedBy: + other: Theme {{ .Theme }} designed by {{ .DesignedBy }} diff --git a/i18n/fr.toml b/i18n/fr.toml deleted file mode 100644 index 03c4efa..0000000 --- a/i18n/fr.toml +++ /dev/null @@ -1,38 +0,0 @@ -[toggleMenu] - other = "Afficher le menu" - -[relatedContents] - other = "Contenus liés" - -[lastUpdatedOn] - other = "Dernière mise à jour le" - -[widgetArchivesTitle] - other = "Archives" - -[widgetArchivesMore] - other = "Autres" - -[widgetTagCloudTitle] - other = "Mots clés" - -[notFoundTitle] - other = "Page non trouvée" - -[notFoundSubtitle] - other = "Cette page n'existe pas." - -[searchTitle] - other = "Rechercher" - -[searchPlaceholder] - other = "Cherchez un article, une publication, etc." - -[searchResultTitle] - other = "#PAGES_COUNT pages (#TIME_SECONDS secondes)" - -[footerBuiltWith] - other = "Généré avec {{ .Generator }}" - -[footerDesignedBy] - other = "Thème {{ .Theme }} conçu par {{ .DesignedBy }}" \ No newline at end of file diff --git a/i18n/fr.yaml b/i18n/fr.yaml new file mode 100644 index 0000000..59cc111 --- /dev/null +++ b/i18n/fr.yaml @@ -0,0 +1,38 @@ +toggleMenu: + other: Afficher le menu + +article: + relatedContents: + other: Contenus liés + lastUpdatedOn: + other: Dernière mise à jour le + +notFound: + title: + other: Page non trouvée + subtitle: + other: Cette page n'existe pas. + +widget: + archives: + title: + other: Archives + more: + other: Autres + tagCloud: + title: + other: Mots clés + +search: + title: + other: Rechercher + placeholder: + other: Cherchez un article, une publication, etc. + resultTitle: + other: "#PAGES_COUNT pages (#TIME_SECONDS secondes)" + +footer: + builtWith: + other: Généré avec {{ .Generator }} + designedBy: + other: Thème {{ .Theme }} conçu par {{ .DesignedBy }} diff --git a/i18n/id.yaml b/i18n/id.yaml new file mode 100644 index 0000000..31cea39 --- /dev/null +++ b/i18n/id.yaml @@ -0,0 +1,38 @@ +toggleMenu: + other: Tampilkan Menu + +article: + relatedContents: + other: Konten terkait + lastUpdatedOn: + other: Terakhir diperbarui pada + +notFound: + title: + other: Not Found + subtitle: + other: Halaman ini tidak ada. + +widget: + archives: + title: + other: Arsip + more: + other: Lebih + tagCloud: + title: + other: Tag + +search: + title: + other: Cari + placeholder: + other: Ketik sesuatu... + resultTitle: + other: "#PAGES_COUNT halaman (#TIME_SECONDS detik)" + +footer: + builtWith: + other: Dibangun dengan {{ .Generator }} + designedBy: + other: Tema {{ .Theme }} dirancang oleh {{ .DesignedBy }} diff --git a/i18n/ja.toml b/i18n/ja.toml deleted file mode 100644 index 0581364..0000000 --- a/i18n/ja.toml +++ /dev/null @@ -1,23 +0,0 @@ -[toggleMenu] - other = "メニューを開く・閉じる" - -[relatedContents] - other = "関連するコンテンツ" - -[lastUpdatedOn] - other = "最終更新" - -[widgetArchivesTitle] - other = "アーカイブ" - -[widgetArchivesMore] - other = "さらに見る" - -[widgetTagCloudTitle] - other = "タグ" - -[notFoundTitle] - other = "404 Not Found" - -[notFoundSubtitle] - other = "指定されたページは存在しません。" \ No newline at end of file diff --git a/i18n/ja.yaml b/i18n/ja.yaml new file mode 100644 index 0000000..e83e531 --- /dev/null +++ b/i18n/ja.yaml @@ -0,0 +1,39 @@ +toggleMenu: + other: メニューを開く・閉じる + +darkMode: + other: ダークモード + +archives: + categories: + other: 分類 + +article: + relatedContents: + other: 関連するコンテンツ + lastUpdatedOn: + other: 最終更新 + +notFound: + title: + other: 404 Not Found + subtitle: + other: 指定されたページは存在しません。 + +widget: + archives: + title: + other: アーカイブ + more: + other: さらに見る + tagCloud: + title: + other: タグ + +search: + title: + other: サーチ + placeholder: + other: 入力... + resultTitle: + other: "#PAGES_COUNT 件 (#TIME_SECONDS 秒)" diff --git a/i18n/ko.toml b/i18n/ko.toml deleted file mode 100644 index 099477c..0000000 --- a/i18n/ko.toml +++ /dev/null @@ -1,38 +0,0 @@ -[toggleMenu] - other = "메뉴 여닫기" - -[relatedContents] - other = "관련 글" - -[lastUpdatedOn] - other ="마지막 수정: " - -[widgetArchivesTitle] - other = "보관함" - -[widgetArchivesMore] - other = "더보기" - -[widgetTagCloudTitle] - other = "태그" - -[notFoundTitle] - other = "찾을 수 없음" - -[notFoundSubtitle] - other = "페이지를 찾을 수 없습니다." - -[searchTitle] - other = "검색" - -[searchPlaceholder] - other = "검색어를 입력하세요..." - -[searchResultTitle] - other = "#PAGES_COUNT 페이지 (#TIME_SECONDS 초)" - -[footerBuiltWith] - other = "{{ .Generator }}로 만듦" - -[footerDesignedBy] - other = "{{ .DesignedBy }}의 {{ .Theme }} 테마 사용 중" \ No newline at end of file diff --git a/i18n/ko.yaml b/i18n/ko.yaml new file mode 100644 index 0000000..d9916cd --- /dev/null +++ b/i18n/ko.yaml @@ -0,0 +1,38 @@ +toggleMenu: + other: 메뉴 여닫기 + +article: + relatedContents: + other: 관련 글 + lastUpdatedOn: + other: "마지막 수정: " + +notFound: + title: + other: 찾을 수 없음 + subtitle: + other: 페이지를 찾을 수 없습니다. + +widget: + archives: + title: + other: 보관함 + more: + other: 더보기 + tagCloud: + title: + other: 태그 + +search: + title: + other: 검색 + placeholder: + other: 검색어를 입력하세요... + resultTitle: + other: "#PAGES_COUNT 페이지 (#TIME_SECONDS 초)" + +footer: + builtWith: + other: "{{ .Generator }}로 만듦" + designedBy: + other: "{{ .DesignedBy }}의 {{ .Theme }} 테마 사용 중" diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml deleted file mode 100644 index 4f7436f..0000000 --- a/i18n/pt-BR.toml +++ /dev/null @@ -1,41 +0,0 @@ -[toggleMenu] - other = "Alternar Menu" - -[relatedContents] - other = "Conteúdos Relacionados" - -[lastUpdatedOn] - other ="Última atualização em" - -[widgetArchivesTitle] - other = "Arquivos" - -[widgetArchivesMore] - other = "Mais" - -[widgetTagCloudTitle] - other = "Tags" - -[categoriesTitle] - other = "Categorias" - -[notFoundTitle] - other = "Não Encontrado" - -[notFoundSubtitle] - other = "Esta página não existe." - -[searchTitle] - other = "Busca" - -[searchPlaceholder] - other = "Digite algo..." - -[searchResultTitle] - other = "#PAGES_COUNT páginas (#TIME_SECONDS segundos)" - -[footerBuiltWith] - other = "Criado com {{ .Generator }}" - -[footerDesignedBy] - other = "Tema {{ .Theme }} desenvolvido por {{ .DesignedBy }}" \ No newline at end of file diff --git a/i18n/pt-BR.yaml b/i18n/pt-BR.yaml new file mode 100644 index 0000000..5380c68 --- /dev/null +++ b/i18n/pt-BR.yaml @@ -0,0 +1,42 @@ +toggleMenu: + other: Alternar Menu + +archives: + categories: + other: Categorias + +article: + relatedContents: + other: Conteúdos Relacionados + lastUpdatedOn: + other: Última atualização em + +notFound: + title: + other: Não Encontrado + subtitle: + other: Esta página não existe. + +widget: + archives: + title: + other: Arquivos + more: + other: Mais + tagCloud: + title: + other: Tags + +search: + title: + other: Busca + placeholder: + other: Digite algo... + resultTitle: + other: "#PAGES_COUNT páginas (#TIME_SECONDS segundos)" + +footer: + builtWith: + other: Criado com {{ .Generator }} + designedBy: + other: Tema {{ .Theme }} desenvolvido por {{ .DesignedBy }} diff --git a/i18n/ru.yaml b/i18n/ru.yaml new file mode 100644 index 0000000..f606ffa --- /dev/null +++ b/i18n/ru.yaml @@ -0,0 +1,61 @@ +toggleMenu: + other: Показать/скрыть меню + +darkMode: + other: Тёмный режим + +list: + page: + one: "{{ .Count }} страница" + few: "{{ .Count }} страницы" + many: "{{ .Count }} страниц" + other: "{{ .Count }} страниц" + + section: + other: Разделы + + subsection: + one: Подраздел + few: Подраздела + many: Подразделов + other: Подразделов + +archives: + categories: + other: Категории + +article: + relatedContents: + other: Также рекомендуем + lastUpdatedOn: + other: Обновлено + +notFound: + title: + other: Не найшено + subtitle: + other: Запрашиваемая страница не существует + +widget: + archives: + title: + other: Архивы + more: + other: Ещё + tagCloud: + title: + other: Теги + +search: + title: + other: Поиск + placeholder: + other: Введите что-нибудь... + resultTitle: + other: "Найдено #PAGES_COUNT страниц (за #TIME_SECONDS с.)" + +footer: + builtWith: + other: Создано при помощи {{ .Generator }} + designedBy: + other: Тема {{ .Theme }} дизайн {{ .DesignedBy }} diff --git a/i18n/tr.yaml b/i18n/tr.yaml new file mode 100644 index 0000000..fbcb7b0 --- /dev/null +++ b/i18n/tr.yaml @@ -0,0 +1,57 @@ +toggleMenu: + other: Menüyü Gizle + +darkMode: + other: Koyu Mod + +list: + page: + one: "{{ .Count }} makale" + other: "{{ .Count }} makale" + + section: + other: Bölüm + + subsection: + one: Alt bölüm + other: Alt bölümler + +archives: + categories: + other: Kategoriler + +article: + relatedContents: + other: Alakalı içerikler + lastUpdatedOn: + other: Son güncelleme + +notFound: + title: + other: Bulunamadı + subtitle: + other: Aradığınız sayfa mevcut değil. + +widget: + archives: + title: + other: Arşiv + more: + other: Daha fazla + tagCloud: + title: + other: Etiketler + +search: + title: + other: Arama + placeholder: + other: Birşeyler yazın... + resultTitle: + other: "#PAGES_COUNT sayfa (#TIME_SECONDS saniye)" + +footer: + builtWith: + other: "{{ .Generator }} ile oluşturuldu." + designedBy: + other: "{{ .Theme }} teması {{ .DesignedBy }} tarafından tasarlandı" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml deleted file mode 100644 index e589330..0000000 --- a/i18n/zh-CN.toml +++ /dev/null @@ -1,32 +0,0 @@ -[toggleMenu] - other = "切换菜单" - -[relatedContents] - other = "相关文章" - -[lastUpdatedOn] - other ="最后更新于" - -[widgetArchivesTitle] - other = "归档" - -[widgetArchivesMore] - other = "更多" - -[widgetTagCloudTitle] - other = "标签云" - -[notFoundTitle] - other = "404 错误" - -[notFoundSubtitle] - other = "页面不存在" - -[searchTitle] - other = "搜索" - -[searchPlaceholder] - other = "输入关键词..." - -[searchResultTitle] - other = "#PAGES_COUNT 个结果 (用时 #TIME_SECONDS 秒)" \ No newline at end of file diff --git a/i18n/zh-CN.yaml b/i18n/zh-CN.yaml new file mode 100644 index 0000000..0583bf7 --- /dev/null +++ b/i18n/zh-CN.yaml @@ -0,0 +1,39 @@ +toggleMenu: + other: 切换菜单 + +darkMode: + other: 暗色模式 + +archives: + categories: + other: 分类 + +article: + relatedContents: + other: 相关文章 + lastUpdatedOn: + other: 最后更新于 + +notFound: + title: + other: 404 错误 + subtitle: + other: 页面不存在 + +widget: + archives: + title: + other: 归档 + more: + other: 更多 + tagCloud: + title: + other: 标签云 + +search: + title: + other: 搜索 + placeholder: + other: 输入关键词... + resultTitle: + other: "#PAGES_COUNT 个结果 (用时 #TIME_SECONDS 秒)" diff --git a/layouts/404.html b/layouts/404.html index dd5e49d..b89d2b6 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,7 +1,7 @@ {{ define "main" }}
-

{{ T "notFoundTitle" }}

-

{{ T "notFoundSubtitle" }}

+

{{ T "notFound.title" }}

+

{{ T "notFound.subtitle" }}

{{ partialCached "footer/footer" . }} {{ end }} \ No newline at end of file diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index dc57481..21f650a 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,19 +1,27 @@ {{- $image := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) -}} {{- if $image -}} - {{- $small := $image.Resize "480x" -}} - {{- $big := $image.Resize "1024x" -}} {{- $alt := .PlainText | safeHTML -}} - {{- $caption := "" -}} - {{- with $alt -}} - {{- $caption = . | safeHTML -}} - {{- end -}} -
+
- {{ if $alt }}{{ $alt }}{{ else if $caption }}{{ $caption | markdownify | plainify }}{{ else }} {{ end }} + {{- $Permalink := $image.RelPermalink -}} + {{- $Width := $image.Width -}} + {{- $Height := $image.Height -}} + {{- $Srcset := "" -}} + + {{- if (default true .Page.Site.Params.imageProcessing.content.enabled) -}} + {{- $small := $image.Resize "480x" -}} + {{- $big := $image.Resize "1024x" -}} + {{- $Srcset = printf "%s 480w, %s 1024w" $small.RelPermalink $big.RelPermalink -}} + {{- end -}} + + - {{ with $caption }} + {{ with $alt }}
{{ . | markdownify }}
{{ end }}
diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 0071565..49c0ddf 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -2,8 +2,8 @@ {{ define "main" }} {{ $categories := ($.Site.GetPage "taxonomyTerm" "categories").Pages }} {{ if $categories }} -

{{ T "categoriesTitle" }}

-
+

{{ T "archives.categories" }}

+
{{ range $categories }} {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 06a31e5..ce0ddae 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -5,7 +5,8 @@ {{- block "head" . -}}{{ end }} -
+ {{- partial "head/colorScheme" . -}} +
{{ partial "sidebar/left.html" . }}
{{- block "main" . }}{{- end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 8bd33d0..b4efb67 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,10 +1,63 @@ {{ define "main" }} -
-

{{ .Title }}

+

+ {{ if eq .Parent (.GetPage "/") }} + {{ T "list.section" }} + {{ else }} + {{ .Parent.Title }} + {{ end }} +

+ +
+
+

{{ T "list.page" (len .Pages) }}

+

{{ .Title }}

+ {{ with .Params.description }} +

{{ . }}

+ {{ end }} +
+ + {{- $image := partialCached "helper/image" (dict "Context" . "Type" "section") .RelPermalink "section" -}} + {{ if $image.exists }} +
+ {{ if $image.resource }} + {{- $Permalink := $image.resource.RelPermalink -}} + {{- $Width := $image.resource.Width -}} + {{- $Height := $image.resource.Height -}} + + {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}} + {{- $thumbnail := $image.resource.Fill "120x120" -}} + {{- $Permalink = $thumbnail.RelPermalink -}} + {{- $Width = $thumbnail.Width -}} + {{- $Height = $thumbnail.Height -}} + {{- end -}} + + + {{ else }} + + {{ end }} +
+ {{ end }}
+ {{ $subsections := .Sections }} + {{ with $subsections }} +

{{ T "list.subsection" (len $subsections) }}

+
+
+ {{ range . }} + {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "section") }} + {{ end }} +
+
+ {{ end }} + + {{/* List only pages that are not a subsection */}} + {{ $paginator := .Paginate (.Pages | complement $subsections) }}
- {{ range .Paginator.Pages }} + {{ range $paginator.Pages }} {{ partial "article-list/compact" . }} {{ end }}
diff --git a/layouts/_default/term.html b/layouts/_default/term.html deleted file mode 100644 index 3bfcc28..0000000 --- a/layouts/_default/term.html +++ /dev/null @@ -1,37 +0,0 @@ -{{ define "main" }} -

{{ .Type | singularize | humanize }}

-
-
-

{{ len .Pages }} post{{ if gt (len .Pages) 1 }}s{{ end }}

-

{{ .Title }}

- {{ with .Params.description }} -

{{ . }}

- {{ end }} -
- - {{- $image := partialCached "helper/image" (dict "Context" . "Type" "taxonomy") .RelPermalink "taxonomy" -}} - {{ if $image.exists }} -
- {{ if $image.resource }} - {{- $thumbnail := $image.resource.Fill "120x120" -}} - - {{ else }} - - {{ end }} -
- {{ end }} -
- -
- {{ $v2 := where .Pages "Params.hidden" "!=" true }} - {{ $pag := .Paginate (.Pages) }} - {{ range $pag.Pages }} - {{ partial "article-list/compact" . }} - {{ end }} -
- - {{- partial "pagination.html" . -}} - - {{ partialCached "footer/footer" . }} -{{ end }} \ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html index b04b926..576faef 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -11,7 +11,7 @@ {{- partial "pagination.html" . -}} - {{ partialCached "footer/footer" . }} + {{- partial "footer/footer" . -}} {{ end }} {{ define "right-sidebar" }} diff --git a/layouts/page/search.html b/layouts/page/search.html index 6078ac1..259d398 100644 --- a/layouts/page/search.html +++ b/layouts/page/search.html @@ -7,8 +7,8 @@ {{ define "main" }}

- - + +