-
Notifications
You must be signed in to change notification settings - Fork 0
⚙️ [Maintenance]: Minor docs-site switch to Zensical #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d05fec9
Make docs pipeline Zensical-only
MariusStorhaug a088cea
Fix Zensical build output handling
MariusStorhaug 75912ac
Constrain Zensical site_dir to project root
MariusStorhaug 6f6c4f4
Use PSModule helper imports
MariusStorhaug 2b5cc1c
Inject nav-state script centrally
MariusStorhaug 528fed2
Fix Build-Site YAML script block
MariusStorhaug d5deb4d
Extract site script injection action
MariusStorhaug 214dfb3
Extract all multiline Build-Site steps
MariusStorhaug 5e8c7ff
Normalize action run blocks
MariusStorhaug 9388dde
Align new actions with MSX standards
MariusStorhaug a69daa5
Document action scripts per MSX standard
MariusStorhaug 3edbe44
Harden composite action input handling
MariusStorhaug 8dedc1a
Fix nav-state JavaScript lint issues
MariusStorhaug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Inject-SiteScripts | ||
| description: Inject shared JavaScript snippets into generated site HTML files. | ||
|
|
||
| inputs: | ||
| SitePath: | ||
| description: Path to the generated site output directory. | ||
| required: true | ||
| WorkflowPath: | ||
| description: Path to the checked out workflow repository root. | ||
| required: false | ||
| default: _wf | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Inject site scripts | ||
| shell: pwsh | ||
| run: | | ||
| & "${{ github.action_path }}/src/inject-site-scripts.ps1" ` | ||
Check warningCode scanning / CodeQL Code injection Medium
Potential code injection in
${ github.action_path } Error loading related location Loading |
||
| -SitePath "${{ inputs.SitePath }}" ` | ||
Check warningCode scanning / CodeQL Code injection Medium
Potential code injection in
${ inputs.SitePath } Error loading related location Loading |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| -WorkflowPath "${{ inputs.WorkflowPath }}" | ||
Check warningCode scanning / CodeQL Code injection Medium
Potential code injection in
${ inputs.WorkflowPath } Error loading related location Loading |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
41 changes: 41 additions & 0 deletions
41
.github/actions/Inject-SiteScripts/src/inject-site-scripts.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| param( | ||
| [Parameter(Mandatory)] | ||
| [string]$SitePath, | ||
|
|
||
| [Parameter(Mandatory)] | ||
| [string]$WorkflowPath | ||
| ) | ||
|
|
||
| $resolvedSitePath = Resolve-Path -Path $SitePath -ErrorAction Stop | Select-Object -ExpandProperty Path | ||
| $injectorsPath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "$WorkflowPath/.github/scripts/site-injectors" | ||
|
|
||
| if (-not (Test-Path -Path $injectorsPath)) { | ||
| throw "Expected site injector folder at $injectorsPath but it was not found." | ||
| } | ||
|
|
||
| $injectorScripts = Get-ChildItem -Path $injectorsPath -File -Filter '*.js' | Sort-Object -Property Name | ||
| if (-not $injectorScripts) { | ||
| Write-Host "No site injector scripts found under $injectorsPath." | ||
| exit 0 | ||
| } | ||
|
|
||
| Get-ChildItem -Path $resolvedSitePath -Filter '*.html' -Recurse | ForEach-Object { | ||
| $html = Get-Content -Path $_.FullName -Raw | ||
| $modified = $false | ||
|
|
||
| foreach ($injectorScript in $injectorScripts) { | ||
| $marker = "data-psmodule-site-injector=""$($injectorScript.Name)""" | ||
| if ($html -match [Regex]::Escape($marker)) { | ||
| continue | ||
| } | ||
|
|
||
| $scriptContent = Get-Content -Path $injectorScript.FullName -Raw | ||
| $injectedScript = "<script $marker>$scriptContent</script>" | ||
| $html = $html -replace '</body>', "$injectedScript`n</body>" | ||
| $modified = $true | ||
| } | ||
|
|
||
| if ($modified) { | ||
| Set-Content -Path $_.FullName -Value $html -NoNewline | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| (() => { | ||
| const storageKey = "zensical-nav-state-v1"; | ||
| let lastSignature = ""; | ||
|
|
||
| const getToggles = () => | ||
| Array.from(document.querySelectorAll("input.md-nav__toggle.md-toggle[id]")); | ||
|
|
||
| const getPrimaryList = () => | ||
| document.querySelector("nav.md-nav--primary > ul.md-nav__list"); | ||
|
|
||
| const applyDefaultTopLevelState = (toggles) => { | ||
| const primaryList = getPrimaryList(); | ||
| if (!primaryList) { | ||
| return; | ||
| } | ||
|
|
||
| const topLevelToggles = Array.from( | ||
| primaryList.querySelectorAll( | ||
| ":scope > li > input.md-nav__toggle.md-toggle[id]" | ||
| ) | ||
| ); | ||
| const topLevelIds = new Set(topLevelToggles.map((toggle) => toggle.id)); | ||
|
|
||
| for (const toggle of toggles) { | ||
| toggle.checked = topLevelIds.has(toggle.id); | ||
| } | ||
| }; | ||
|
|
||
| const restoreState = (toggles) => { | ||
| const raw = localStorage.getItem(storageKey); | ||
| if (!raw) { | ||
| applyDefaultTopLevelState(toggles); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| const state = JSON.parse(raw); | ||
| for (const toggle of toggles) { | ||
| if (Object.prototype.hasOwnProperty.call(state, toggle.id)) { | ||
| toggle.checked = !!state[toggle.id]; | ||
| } | ||
| } | ||
| } catch { | ||
| applyDefaultTopLevelState(toggles); | ||
| } | ||
| }; | ||
|
|
||
| const persistState = (toggles) => { | ||
| const state = {}; | ||
| for (const toggle of toggles) { | ||
| state[toggle.id] = !!toggle.checked; | ||
| } | ||
| localStorage.setItem(storageKey, JSON.stringify(state)); | ||
| }; | ||
|
|
||
| const initialize = () => { | ||
| const toggles = getToggles(); | ||
| if (toggles.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| const signature = toggles.map((toggle) => toggle.id).join("|"); | ||
| if (signature === lastSignature) { | ||
| return; | ||
| } | ||
|
|
||
| lastSignature = signature; | ||
| restoreState(toggles); | ||
| for (const toggle of toggles) { | ||
| if (toggle.dataset.navStateBound === "true") { | ||
| continue; | ||
| } | ||
|
|
||
| toggle.dataset.navStateBound = "true"; | ||
| toggle.addEventListener("change", () => persistState(getToggles())); | ||
| } | ||
| }; | ||
|
|
||
| if (document.readyState === "loading") { | ||
| document.addEventListener("DOMContentLoaded", initialize, { once: true }); | ||
| } else { | ||
| initialize(); | ||
| } | ||
|
|
||
| setInterval(initialize, 500); | ||
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| [project] | ||
| site_name = "-{{ REPO_NAME }}-" | ||
| repo_name = "-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-" | ||
| repo_url = "https://github.com/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-" | ||
|
|
||
| [project.theme] | ||
| variant = "classic" | ||
| language = "en" | ||
| logo = "Assets/icon.png" | ||
| favicon = "Assets/icon.png" | ||
| features = [ | ||
| "navigation.instant", | ||
| "navigation.instant.progress", | ||
| "navigation.indexes", | ||
| "navigation.top", | ||
| "navigation.tracking", | ||
| "navigation.expand", | ||
| "search.suggest", | ||
| "search.highlight", | ||
| "content.code.copy" | ||
| ] | ||
|
|
||
| [[project.theme.palette]] | ||
| media = "(prefers-color-scheme)" | ||
| toggle.icon = "lucide/sun-moon" | ||
| toggle.name = "Switch to dark mode" | ||
|
|
||
| [[project.theme.palette]] | ||
| media = "(prefers-color-scheme: dark)" | ||
| scheme = "slate" | ||
| primary = "black" | ||
| accent = "green" | ||
| toggle.icon = "lucide/moon" | ||
| toggle.name = "Switch to light mode" | ||
|
|
||
| [[project.theme.palette]] | ||
| media = "(prefers-color-scheme: light)" | ||
| scheme = "default" | ||
| primary = "indigo" | ||
| accent = "green" | ||
| toggle.icon = "lucide/sun" | ||
| toggle.name = "Switch to system preference" | ||
|
|
||
| [project.theme.icon] | ||
| repo = "fontawesome/brands/github" | ||
|
|
||
| [project.markdown_extensions.toc] | ||
| permalink = true | ||
|
|
||
| [project.markdown_extensions.attr_list] | ||
| [project.markdown_extensions.admonition] | ||
| [project.markdown_extensions.md_in_html] | ||
| [project.markdown_extensions.pymdownx.details] | ||
| [project.markdown_extensions.pymdownx.superfences] | ||
|
|
||
| [[project.extra.social]] | ||
| icon = "fontawesome/brands/discord" | ||
| link = "https://discord.gg/jedJWCPAhD" | ||
| name = "-{{ REPO_OWNER }}- on Discord" | ||
|
|
||
| [[project.extra.social]] | ||
| icon = "fontawesome/brands/github" | ||
| link = "https://github.com/-{{ REPO_OWNER }}-/" | ||
| name = "-{{ REPO_OWNER }}- on GitHub" | ||
|
|
||
| [project.extra.consent] | ||
| title = "Cookie consent" | ||
| description = "We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better." | ||
| actions = ["accept", "reject"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.