Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hossainemruz authored Jan 13, 2025
2 parents f612a95 + 047bb51 commit 3988262
Show file tree
Hide file tree
Showing 58 changed files with 3,187 additions and 1,121 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/autoprefixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout to latest commit
uses: actions/checkout@v4.1.5
uses: actions/checkout@v4.2.2

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "15.x"
node-version: "20.x"

- name: Run autoprefixer
run: |
npm install postcss postcss-cli autoprefixer --save-dev
npm run autoprefixer
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
branch: autoprefixer
branch-suffix: timestamp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.5
uses: actions/checkout@v4.2.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/enforce-lablel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Label Enforcer

# Run action on pull request creation, reopening, or label changes
on:
pull_request:
types: [opened, reopened, labeled, unlabeled]

jobs:
# Ensure that PR has desired labels
enforce-label:
runs-on: ubuntu-latest
steps:
- uses: yogevbd/[email protected]
with:
REQUIRED_LABELS_ANY: "automerge,breaking-change,bug-fix,enhancement,feature,translation"
REQUIRED_LABELS_ANY_DESCRIPTION: "The PR must have at least one these labels: ['automerge','breaking-change','bug-fix','enhancement','feature','translation']"
15 changes: 3 additions & 12 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# checkout to the commit that has been pushed
- uses: actions/checkout@v4.1.5
- uses: actions/checkout@v4.2.2

- name: Setup Node
uses: actions/setup-node@v4
Expand All @@ -35,7 +35,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.5
- uses: actions/checkout@v4.2.2

- name: Setup Node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -73,20 +73,11 @@ jobs:
timeout: 5
urls: "${{ steps.preview.outputs.url }},${{ steps.preview.outputs.url }}/posts/,${{ steps.preview.outputs.url }}/posts/markdown-sample/,${{ steps.preview.outputs.url }}/posts/shortcodes/"

# Ensure that PR has desired labels
enforce-label:
runs-on: ubuntu-latest
steps:
- uses: yogevbd/[email protected]
with:
REQUIRED_LABELS_ANY: "automerge,breaking-change,bug-fix,enhancement,feature,translation"
REQUIRED_LABELS_ANY_DESCRIPTION: "The PR must have at least one these labels: ['automerge','breaking-change','bug-fix','enhancement','feature','translation']"

# Check for any broken links
markdown-link-check:
runs-on: ubuntu-latest
steps:
# checkout to latest commit
- uses: actions/checkout@v4.1.5
- uses: actions/checkout@v4.2.2
# run markdown linter
- uses: gaurav-nelson/[email protected]
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ A [Hugo](https://gohugo.io/) theme for a personal portfolio with minimalist desi
- counter.dev
- Google Analytics
- Matomo/Piwik
- [Umami](https://umami.is/)
- Comment Support
- [Disqus](https://disqus.com/)
- [Valine](https://valine.js.org/)
Expand All @@ -55,13 +56,15 @@ For more details about the features please visit [here](https://toha-guides.netl
- Deutsch
- Español
- 简体中文
- 繁體中文
- हिन्दी
- Italiano
- 日本語
- 한국어
- русский
- suomi
- Tiếng Việt
- Azerbaijan
- Turkish
- Arabic (العربية)
- Português Europeu
Expand Down Expand Up @@ -90,7 +93,7 @@ Here are few screenshots from the [example site](https://hugo-toha.github.io).

## Requirements

- Hugo Version 0.118.0 (extended) or higher
- Hugo Version 0.128.0 (extended) or higher
- Go language 1.18 or higher (require for hugo modules)
- Node version v18.x or later and npm 8.x or later.

Expand All @@ -110,7 +113,7 @@ hugo mod init github.com/<your username>/<your repo name>

##### 2. Add this theme as your module dependency

Now, in your `config.yaml` file, add a `module` section.
Now, in your `hugo.yaml` file, add a `module` section.

```yaml
# Use Hugo modules to add theme
Expand All @@ -119,7 +122,7 @@ module:
- path: github.com/hugo-toha/toha/v4
```
Check this sample [config.yaml](https://github.com/hugo-toha/hugo-toha.github.io/blob/main/config.yaml) for further reference.
Check this sample [hugo.yaml](https://github.com/hugo-toha/hugo-toha.github.io/blob/main/hugo.yaml) for further reference.
##### 3. Update your module
Expand Down Expand Up @@ -206,7 +209,7 @@ $ npm install
$ hugo server -w
```

Now, you can make change in the theme and they will be reflected immediately on the running site. If you need to change any configuration, you can do that in the `config.yaml` file inside `exampleSite` folder. If you need to add any content or data, you can create the respective folder inside `exampleSite` directory and add your desired content or data there.
Now, you can make change in the theme and they will be reflected immediately on the running site. If you need to change any configuration, you can do that in the `hugo.yaml` file inside `exampleSite` folder. If you need to add any content or data, you can create the respective folder inside `exampleSite` directory and add your desired content or data there.

#### Running the forked theme against your own site

Expand Down
9 changes: 9 additions & 0 deletions assets/scripts/core/theme-scheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let theme = localStorage.getItem('theme-scheme') || localStorage.getItem('darkmode:color-scheme') || 'light'
if (theme === 'system') {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
theme = 'dark'
} else {
theme = 'light'
}
}
document.documentElement.setAttribute('data-theme', theme)
22 changes: 22 additions & 0 deletions assets/scripts/features/copyCode/copyCode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
addCopyButtons(navigator.clipboard)

function addCopyButtons(clipboard) {
document.querySelectorAll('pre > code').forEach(function (codeBlock) {
const button = document.createElement('button')
button.title = "Copy"
button.className = 'copy-code-button btn btn-sm'
button.innerHTML = "<i class='fa-regular fa-copy'></i>"

button.addEventListener('click', function () {
clipboard.writeText(codeBlock.innerText)
})

const pre = codeBlock.parentNode
if (pre.parentNode.classList.contains('highlight')) {
const highlight = pre.parentNode
highlight.parentNode.insertBefore(button, highlight)
} else {
pre.parentNode.insertBefore(button, pre)
}
})
}
1 change: 1 addition & 0 deletions assets/scripts/features/copyCode/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './copyCode'
8 changes: 8 additions & 0 deletions assets/scripts/features/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if (process.env.FEATURE_DARKMODE === '1') {
import('./darkmode')
}

if (process.env.FEATURE_THEME === '1') {
import('./theme')
}

if (process.env.FEATURE_FLOWCHART === '1') {
import('./flowchart')
}
Expand All @@ -25,3 +29,7 @@ if (process.env.FEATURE_MATH === '1') {
if (process.env.FEATURE_EMBEDPDF === '1') {
import('./embedpdf')
}

if (process.env.FEATURE_COPYCODEBUTTON === '1') {
import('./copyCode')
}
88 changes: 88 additions & 0 deletions assets/scripts/features/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import * as params from '@params';
const PERSISTENCE_KEY = 'theme-scheme'

const themeOptions = params.theme || {}
const THEME_DARK = typeof themeOptions.dark === 'undefined' ? true : themeOptions.dark;
const THEME_LIGHT = typeof themeOptions.light === 'undefined' ? true : themeOptions.light;
const THEME_DEFAULT = typeof themeOptions.default === 'undefined' ? "system" : themeOptions.default;

window.addEventListener('load', async () => {
const menu = document.getElementById('themeMenu')
const $icon = document.getElementById('navbar-theme-icon-svg')
if (menu == null || $icon == null) return

const btns = menu.getElementsByTagName('a')
const iconMap = Array.from(btns).reduce((map, btn) => {
const $img = btn.getElementsByTagName('img')[0]
map[btn.dataset.scheme] = $img.src
return map
}, {})


function checkScheme(scheme) {
if (THEME_LIGHT === false) return "dark"
if (THEME_DARK === false) return "light"
return scheme
}

function loadScheme() {
return localStorage.getItem(PERSISTENCE_KEY) || loadDefaultScheme()
}

function loadDefaultScheme() {
return THEME_DEFAULT || "system"
}

function saveScheme(scheme) {
localStorage.setItem(PERSISTENCE_KEY, scheme)
}

function getPreferredColorScheme() {
const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
return isDarkMode ? "dark" : "light";
}

function setScheme(newScheme) {
let theme = newScheme
if (newScheme === 'system') {
theme = getPreferredColorScheme()
}
// set data-theme attribute on html tag
document.querySelector("html").dataset.theme = theme;

// update icon
$icon.src = iconMap[newScheme]

// save preference to local storage
saveScheme(newScheme)

setImages(theme)
}

const checkedScheme = checkScheme(loadScheme())
setScheme(checkedScheme)

Array.from(menu.getElementsByTagName('a')).forEach((btn) => {
btn.addEventListener('click', () => {
const { scheme } = btn.dataset
setScheme(scheme)
})
})
})

function setImages(newScheme) {
const els = Array.from(document.getElementsByClassName('logo-holder'));
for (const el of els) {
const light = el.querySelector('.light-logo');
const dark = el.querySelector('.dark-logo');

if (newScheme === "dark" && dark !== null) {
if (light !== null) light.style.display = 'none'
dark.style.display = 'inline'
}
else {
if (light !== null) light.style.display = 'inline'
if (dark !== null) dark.style.display = 'none'
}
}
}
2 changes: 1 addition & 1 deletion assets/scripts/pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.addEventListener('DOMContentLoaded', () => {
const fuseOptions = {
shouldSort: true,
includeMatches: true,
threshold: 0.0,
threshold: 0.1,
tokenize: true,
location: 0,
distance: 100,
Expand Down
1 change: 1 addition & 0 deletions assets/scripts/sections/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import './sidebar'
import './education'
import './achievements'
import './projects'
import './skills'
import './publications'
15 changes: 15 additions & 0 deletions assets/scripts/sections/skills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Filterizr from 'filterizr'

document.addEventListener('DOMContentLoaded', () => {
// ================== Skill cards =====================

// setup skill filter buttons
const skillCardHolder = document.getElementById('skill-card-holder')
if (skillCardHolder != null && skillCardHolder.children.length !== 0) {
// eslint-disable-next-line no-new
new Filterizr('.filtr-skills', {
layout: 'sameWidth',
controlsSelector: '.skill-filtr-control'
})
}
})
45 changes: 45 additions & 0 deletions assets/styles/components/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,40 @@
}
}

.copy-code-button {
float: right;
margin-top: 0.5em;
margin-left: -2.6em;
margin-right: 3em;

background-color: get-light-color('text-color') !important;
color: get-light-color('inverse-text-color') !important;
padding: 0.25rem 0.5rem;
line-height: 1.5;
border-radius: 0.2rem;
border: none;

&:hover,
&:focus {
background-color: get-light-color('accent-color') !important;
color: get-light-color('text-over-accent-color') !important;
@include transition();
}
&:focus {
&::before {
content: 'Copied!';
position: absolute;
padding: 0.3em;
border-radius: 0.2em;
margin-left: -5em;
margin-top: -0.2em;
background-color: get-light-color('accent-color') !important;
color: get-light-color('text-over-accent-color') !important;
@include transition();
}
}
}

html[data-theme='dark'] {
.btn-dark {
background-color: get-dark-color('accent-color') !important;
Expand Down Expand Up @@ -169,4 +203,15 @@ html[data-theme='dark'] {
background-color: get-dark-color('hover-over-accent-color') !important;
}
}
.copy-code-button {
background-color: get-dark-color('bg-primary') !important;
color: get-dark-color('muted-text-color') !important;

&:hover,
&:focus,
&::before {
background-color: get-dark-color('accent-color') !important;
color: get-dark-color('text-over-accent-color') !important;
}
}
}
Loading

0 comments on commit 3988262

Please sign in to comment.