Skip to content

Docs: unminify downloadable example HTML files #41637

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 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions build/zip-examples.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import fs from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import sh from 'shelljs'
import { format } from 'prettier'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -83,16 +84,34 @@ for (const file of staticJsFiles) {
sh.rm(`${distFolder}/index.html`)

// get all examples' HTML files
for (const file of sh.find(`${distFolder}/**/*.html`)) {
const htmlFiles = sh.find(`${distFolder}/**/*.html`)

const formatPromises = htmlFiles.map(async file => {
const fileContents = sh.cat(file)
.toString()
.replace(new RegExp(`"/docs/${versionShort}/`, 'g'), '"../')
.replace(/"..\/dist\//g, '"../assets/dist/')
.replace(/(<link href="\.\.\/[^"]*"[^>]*) integrity="[^"]*"/g, '$1')
.replace(/<link[^>]*href="\.\.\/assets\/img\/favicons\/[^"]*"[^>]*>/g, '')
.replace(/(<script src="\.\.\/[^"]*"[^>]*) integrity="[^"]*"/g, '$1')
new sh.ShellString(fileContents).to(file)
}

let formattedHTML
try {
formattedHTML = await format(fileContents, {
parser: 'html',
filepath: file
})
} catch (error) {
console.error(`\nError formatting ${file}:`)
console.error(`Message: ${error.message}`)
console.error('\nSkipping formatting for this file...\n')
formattedHTML = fileContents
}

new sh.ShellString(formattedHTML).to(file)
})

await Promise.all(formatPromises)

// create the zip file
sh.exec(`zip -qr9 "${distFolder}.zip" "${distFolder}"`)
Expand Down
5 changes: 2 additions & 3 deletions site/src/assets/examples/cheatsheet-rtl/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,7 @@ import Placeholder from "@shortcodes/Placeholder.astro"
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src=${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')} width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy"
style="filter: invert(1) grayscale(100%) brightness(200%);">
<img src="${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')}" width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy" style="filter: invert(1) grayscale(100%) brightness(200%);">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="تبديل التنقل">
<span class="navbar-toggler-icon"></span>
Expand Down Expand Up @@ -1249,7 +1248,7 @@ import Placeholder from "@shortcodes/Placeholder.astro"
<nav class="navbar navbar-expand-lg navbar-dark bg-primary mt-5">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src=${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')} width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy">
<img src="${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')}" width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent2" aria-controls="navbarSupportedContent2" aria-expanded="false" aria-label="تبديل التنقل">
<span class="navbar-toggler-icon"></span>
Expand Down
5 changes: 2 additions & 3 deletions site/src/assets/examples/cheatsheet/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,7 @@ export const body_class = 'bg-body-tertiary'
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src=${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')} width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy"
style="filter: invert(1) grayscale(100%) brightness(200%);">
<img src="${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')}" width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy" style="filter: invert(1) grayscale(100%) brightness(200%);">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand Down Expand Up @@ -1227,7 +1226,7 @@ export const body_class = 'bg-body-tertiary'
<nav class="navbar navbar-expand-lg navbar-dark bg-primary mt-5">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src=${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')} width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy">
<img src="${getVersionedDocsPath('/assets/brand/bootstrap-logo-white.svg')}" width="38" height="30" class="d-inline-block align-top" alt="Bootstrap" loading="lazy">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent2" aria-controls="navbarSupportedContent2" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand Down