Skip to content

Commit 4cb6504

Browse files
feat(docs): add prettier-plugin-bootstrap for automatic class sorting
Adds `prettier-plugin-bootstrap` (v0.3.0) to automatically sort Bootstrap CSS classes following the framework's architecture order. - Adds `prettier-plugin-bootstrap@^0.3.0` as a dev dependency - Configures `.prettierrc.json` with the plugin (after prettier-plugin-astro) - Reformats 28 `.astro` files with sorted class attributes (no functional changes) Plugin features: - Sorts classes: layout → components → helpers → utilities - Responsive variants sort after their base class - Supports HTML, JSX/TSX, Vue, Angular, Svelte, and Astro - Public sorting API via `prettier-plugin-bootstrap/sorter` - 121 tests, 100% coverage, zero runtime dependencies Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
1 parent d70b829 commit 4cb6504

27 files changed

Lines changed: 111 additions & 95 deletions

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
"postcss-cli": "^11.0.1",
168168
"prettier": "^3.8.3",
169169
"prettier-plugin-astro": "^0.14.1",
170+
"prettier-plugin-bootstrap": "^0.3.0",
170171
"rehype-autolink-headings": "^7.1.0",
171172
"remark": "^15.0.1",
172173
"remark-html": "^16.0.1",

site/.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"printWidth": 120,
66
"semi": false,
77
"singleQuote": true,
8-
"trailingComma": "none"
8+
"trailingComma": "none",
9+
"plugins": ["prettier-plugin-astro", "prettier-plugin-bootstrap"]
910
}

site/src/components/Ads.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2+
23
---
34

45
<script
56
is:inline
67
async
78
src="https://cdn.carbonads.com/carbon.js?serve=CKYIKKJL&placement=getbootstrapcom"
8-
id="_carbonads_js"
9-
></script>
9+
id="_carbonads_js"></script>

site/src/components/DocsSidebar.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { getSlug } from '@libs/utils'
77
const sidebar = getData('sidebar')
88
---
99

10-
<nav class="bd-links w-100" id="bd-docs-nav" aria-label="Docs navigation">
11-
<ul class="bd-links-nav list-unstyled mb-0 pb-3 pb-md-2 pe-lg-2">
10+
<nav class="w-100 bd-links" id="bd-docs-nav" aria-label="Docs navigation">
11+
<ul class="list-unstyled mb-0 pe-lg-2 pb-3 pb-md-2 bd-links-nav">
1212
{
1313
sidebar.map((group) => {
1414
const groupSlug = getSlug(group.title)

site/src/components/footer/Footer.astro

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { getConfig } from '@libs/config'
44
import { getVersionedDocsPath } from '@libs/path'
55
---
66

7-
<footer class="bd-footer py-4 py-md-5 mt-5 bg-body-tertiary">
8-
<div class="container py-4 py-md-5 px-4 px-md-3 text-body-secondary">
7+
<footer class="mt-5 py-4 py-md-5 bg-body-tertiary bd-footer">
8+
<div class="container px-4 px-md-3 py-4 py-md-5 text-body-secondary">
99
<div class="row">
1010
<div class="col-lg-3 mb-3">
1111
<a
12-
class="d-inline-flex align-items-center mb-2 text-body-emphasis text-decoration-none"
12+
class="d-inline-flex align-items-center mb-2 text-decoration-none text-body-emphasis"
1313
href="/"
1414
aria-label="Bootstrap"
1515
>
@@ -32,7 +32,7 @@ import { getVersionedDocsPath } from '@libs/path'
3232
<li class="mb-2">Currently v{getConfig().current_version}.</li>
3333
</ul>
3434
</div>
35-
<div class="col-6 col-lg-2 offset-lg-1 mb-3">
35+
<div class="col-lg-2 col-6 offset-lg-1 mb-3">
3636
<h5>Links</h5>
3737
<ul class="list-unstyled">
3838
<li class="mb-2"><a href="/">Home</a></li>
@@ -43,7 +43,7 @@ import { getVersionedDocsPath } from '@libs/path'
4343
<li class="mb-2"><a href={getConfig().swag} target="_blank" rel="noopener">Swag Store</a></li>
4444
</ul>
4545
</div>
46-
<div class="col-6 col-lg-2 mb-3">
46+
<div class="col-lg-2 col-6 mb-3">
4747
<h5>Guides</h5>
4848
<ul class="list-unstyled">
4949
<li class="mb-2"><a href={getVersionedDocsPath('getting-started')}>Getting started</a></li>
@@ -53,7 +53,7 @@ import { getVersionedDocsPath } from '@libs/path'
5353
<li class="mb-2"><a href={getVersionedDocsPath('getting-started/vite')}>Vite</a></li>
5454
</ul>
5555
</div>
56-
<div class="col-6 col-lg-2 mb-3">
56+
<div class="col-lg-2 col-6 mb-3">
5757
<h5>Projects</h5>
5858
<ul class="list-unstyled">
5959
<li class="mb-2">
@@ -69,7 +69,7 @@ import { getVersionedDocsPath } from '@libs/path'
6969
</li>
7070
</ul>
7171
</div>
72-
<div class="col-6 col-lg-2 mb-3">
72+
<div class="col-lg-2 col-6 mb-3">
7373
<h5>Community</h5>
7474
<ul class="list-unstyled">
7575
<li class="mb-2">

site/src/components/header/LinkItem.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const { active, class: className, track, ...props } = Astro.props
1313
const content = await Astro.slots.render('default')
1414
---
1515

16-
<li class="nav-item col-6 col-lg-auto">
16+
<li class="col-lg-auto col-6 nav-item">
1717
<a
1818
aria-current={active ? true : undefined}
1919
class:list={['nav-link py-2 px-0 px-lg-2', className, { active }]}

site/src/components/header/Navigation.astro

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ interface Props {
2121
const { addedIn, layout, title } = Astro.props
2222
---
2323

24-
<header class="navbar navbar-expand-lg bd-navbar sticky-top">
25-
<nav class="container-xxl bd-gutter flex-wrap flex-lg-nowrap" aria-label="Main navigation">
24+
<header class="navbar navbar-expand-lg sticky-top bd-navbar">
25+
<nav class="container-xxl flex-wrap flex-lg-nowrap bd-gutter" aria-label="Main navigation">
2626
{
2727
layout === 'docs' && (
2828
<div class="bd-navbar-toggle">
@@ -42,7 +42,7 @@ const { addedIn, layout, title } = Astro.props
4242
}
4343
{layout !== 'docs' && <div class="d-lg-none" style="width: 4.25rem;" />}
4444

45-
<a class="navbar-brand p-0 me-0 me-lg-2" href="/" aria-label="Bootstrap">
45+
<a class="navbar-brand me-0 me-lg-2 p-0" href="/" aria-label="Bootstrap">
4646
<BootstrapWhiteFillIcon class="d-block my-1" height={32} width={40} />
4747
</a>
4848

@@ -77,7 +77,7 @@ const { addedIn, layout, title } = Astro.props
7777
data-bs-target="#bdNavbar"></button>
7878
</div>
7979

80-
<div class="offcanvas-body p-4 pt-0 p-lg-0">
80+
<div class="offcanvas-body p-4 p-lg-0 pt-0">
8181
<hr class="d-lg-none text-white-50" />
8282
<ul class="navbar-nav flex-row flex-wrap bd-navbar-nav">
8383
<LinkItem active={layout === 'docs'} href={getVersionedDocsPath('getting-started/introduction/')} track>
@@ -91,36 +91,36 @@ const { addedIn, layout, title } = Astro.props
9191
<hr class="d-lg-none text-white-50" />
9292

9393
<ul class="navbar-nav flex-row flex-wrap ms-md-auto">
94-
<LinkItem class="nav-link py-2 px-0 px-lg-2" href={getConfig().github_org} target="_blank" rel="noopener">
94+
<LinkItem class="nav-link px-0 px-lg-2 py-2" href={getConfig().github_org} target="_blank" rel="noopener">
9595
<GitHubIcon class="navbar-nav-svg" height={16} width={16} />
9696
<small class="d-lg-none ms-2">GitHub</small>
9797
</LinkItem>
9898
<LinkItem
99-
class="nav-link py-2 px-0 px-lg-2"
99+
class="nav-link px-0 px-lg-2 py-2"
100100
href={`https://x.com/${getConfig().x}`}
101101
target="_blank"
102102
rel="noopener"
103103
>
104104
<XIcon class="navbar-nav-svg" height={16} width={16} />
105105
<small class="d-lg-none ms-2">X</small>
106106
</LinkItem>
107-
<LinkItem class="nav-link py-2 px-0 px-lg-2" href={getConfig().opencollective} target="_blank" rel="noopener">
107+
<LinkItem class="nav-link px-0 px-lg-2 py-2" href={getConfig().opencollective} target="_blank" rel="noopener">
108108
<OpenCollectiveIcon class="navbar-nav-svg" height={16} width={16} />
109109
<small class="d-lg-none ms-2">Open Collective</small>
110110
</LinkItem>
111-
<li class="nav-item py-2 py-lg-1 col-12 col-lg-auto">
111+
<li class="col-lg-auto col-12 nav-item py-2 py-lg-1">
112112
<div class="vr d-none d-lg-flex h-100 mx-lg-2 text-white"></div>
113113
<hr class="d-lg-none my-2 text-white-50" />
114114
</li>
115115

116116
<Versions layout={layout} addedIn={addedIn} />
117117

118-
<li class="nav-item py-2 py-lg-1 col-12 col-lg-auto">
118+
<li class="col-lg-auto col-12 nav-item py-2 py-lg-1">
119119
<div class="vr d-none d-lg-flex h-100 mx-lg-2 text-white"></div>
120120
<hr class="d-lg-none my-2 text-white-50" />
121121
</li>
122122

123-
<li class="nav-item dropdown">
123+
<li class="dropdown nav-item">
124124
<ThemeToggler layout={layout} />
125125
</li>
126126
</ul>

site/src/components/header/Skippy.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ interface Props {
88
const { layout } = Astro.props
99
---
1010

11-
<div class="skippy visually-hidden-focusable overflow-hidden">
11+
<div class="visually-hidden-focusable overflow-hidden skippy">
1212
<div class="container-xl">
13-
<a class="d-inline-flex p-2 m-1" href="#content">Skip to main content</a>
13+
<a class="d-inline-flex m-1 p-2" href="#content">Skip to main content</a>
1414
{
1515
layout === 'docs' && (
1616
<a class="d-none d-md-inline-flex p-2 m-1" href="#bd-docs-nav">

site/src/components/header/Versions.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ const addedIn52 = addedIn?.version === '5.2'
2727
const addedIn53 = addedIn?.version === '5.3'
2828
---
2929

30-
<li class="nav-item dropdown">
30+
<li class="dropdown nav-item">
3131
<button
3232
type="button"
33-
class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle"
33+
class="btn btn-link dropdown-toggle nav-link px-0 px-lg-2 py-2"
3434
data-bs-toggle="dropdown"
3535
aria-expanded="false"
3636
data-bs-display="static"
@@ -44,7 +44,7 @@ const addedIn53 = addedIn?.version === '5.3'
4444
<li><h6 class="dropdown-header">v5 releases</h6></li>
4545
<li>
4646
<a
47-
class="dropdown-item d-flex align-items-center justify-content-between active"
47+
class="dropdown-item d-flex justify-content-between align-items-center active"
4848
aria-current="true"
4949
href={isHome ? '/' : `/docs/${getConfig().docs_version}/${versionsLink}`}
5050
>

0 commit comments

Comments
 (0)