@defra/docusaurus-theme-govuk 0.0.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/index.js +215 -0
- package/package.json +44 -0
- package/src/css/components.scss +90 -0
- package/src/css/doc-overrides.css +19 -0
- package/src/css/prose-scope.scss +59 -0
- package/src/css/theme.scss +18 -0
- package/src/lib/empty-module.js +2 -0
- package/src/lib/react-foundry-router-shim.js +68 -0
- package/src/theme/Admonition/index.js +33 -0
- package/src/theme/AnnouncementBar/index.js +5 -0
- package/src/theme/CodeBlock/index.js +55 -0
- package/src/theme/DocItem/Content/index.js +28 -0
- package/src/theme/DocItem/Footer/index.js +5 -0
- package/src/theme/DocItem/Layout/index.js +10 -0
- package/src/theme/DocItem/Metadata/index.js +17 -0
- package/src/theme/DocItem/Paginator/index.js +36 -0
- package/src/theme/DocItem/TOC/Desktop/index.js +5 -0
- package/src/theme/DocItem/TOC/Mobile/index.js +5 -0
- package/src/theme/DocItem/docContext.js +37 -0
- package/src/theme/DocItem/index.js +22 -0
- package/src/theme/DocPage/Layout/index.js +5 -0
- package/src/theme/DocRoot/Layout/index.js +10 -0
- package/src/theme/DocRoot/index.js +18 -0
- package/src/theme/DocVersionRoot/index.js +6 -0
- package/src/theme/DocsRoot/index.js +6 -0
- package/src/theme/Heading/index.js +29 -0
- package/src/theme/Homepage/index.js +47 -0
- package/src/theme/Layout/Provider/index.js +5 -0
- package/src/theme/Layout/index.js +181 -0
- package/src/theme/MDXComponents/index.js +42 -0
- package/src/theme/MDXContent/index.js +7 -0
- package/src/theme/NotFound/Content/index.js +23 -0
- package/src/theme/NotFound/index.js +11 -0
- package/src/theme/Root/index.js +5 -0
- package/src/theme/TOCItems/index.js +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Crown Copyright (Defra)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# docusaurus-theme-govuk
|
|
2
|
+
|
|
3
|
+
A Docusaurus 3 theme that applies the [GOV.UK Design System](https://design-system.service.gov.uk/) to your documentation site.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Full GOV.UK Design System shell: Header (with crown crest), Service Navigation, Phase Banner, Footer
|
|
8
|
+
- GOV.UK typography applied to all Markdown/MDX content via prose scoping
|
|
9
|
+
- Sidebar navigation driven by configuration (not Docusaurus's built-in sidebar UI)
|
|
10
|
+
- Syntax-highlighted code blocks with copy button
|
|
11
|
+
- Admonition blocks (:::note, :::warning, etc.) rendered as GOV.UK InsetText / WarningText
|
|
12
|
+
- 404 page with GOV.UK styling
|
|
13
|
+
- Bundled GDS Transport fonts and GOV.UK static assets
|
|
14
|
+
- Compatible with React 18 and React 19
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install docusaurus-theme-govuk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
Update your `docusaurus.config.js` (or `.cjs`):
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
module.exports = {
|
|
28
|
+
title: 'My Service',
|
|
29
|
+
tagline: 'Service documentation',
|
|
30
|
+
url: 'https://example.gov.uk',
|
|
31
|
+
baseUrl: '/',
|
|
32
|
+
|
|
33
|
+
// Remove presets — the theme replaces preset-classic
|
|
34
|
+
presets: [],
|
|
35
|
+
|
|
36
|
+
// Register the GOV.UK theme
|
|
37
|
+
themes: ['docusaurus-theme-govuk'],
|
|
38
|
+
|
|
39
|
+
// Use plugin-content-docs directly for Markdown processing
|
|
40
|
+
plugins: [
|
|
41
|
+
[
|
|
42
|
+
'@docusaurus/plugin-content-docs',
|
|
43
|
+
{
|
|
44
|
+
routeBasePath: '/',
|
|
45
|
+
sidebarPath: require.resolve('./sidebars.js'),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
],
|
|
49
|
+
|
|
50
|
+
// GOV.UK theme configuration
|
|
51
|
+
themeConfig: {
|
|
52
|
+
govuk: {
|
|
53
|
+
header: {
|
|
54
|
+
serviceName: 'My Service',
|
|
55
|
+
serviceHref: '/',
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
navigation: [
|
|
59
|
+
{
|
|
60
|
+
text: 'Documentation',
|
|
61
|
+
href: '/',
|
|
62
|
+
sidebar: [
|
|
63
|
+
{ text: 'Introduction', href: '/' },
|
|
64
|
+
{ text: 'Getting Started', href: '/getting-started' },
|
|
65
|
+
{
|
|
66
|
+
text: 'API Reference',
|
|
67
|
+
href: '/api',
|
|
68
|
+
items: [
|
|
69
|
+
{ text: 'Methods', href: '/methods' },
|
|
70
|
+
{ text: 'Events', href: '/events' },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
|
|
77
|
+
phaseBanner: {
|
|
78
|
+
phase: 'alpha',
|
|
79
|
+
text: 'This is a new service – your feedback will help us to improve it.',
|
|
80
|
+
feedbackHref: '/feedback',
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
footer: {
|
|
84
|
+
meta: [
|
|
85
|
+
{ text: 'GitHub', href: 'https://github.com/your-org/your-repo' },
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Configuration Reference
|
|
94
|
+
|
|
95
|
+
#### `themeConfig.govuk.header`
|
|
96
|
+
|
|
97
|
+
| Property | Type | Description |
|
|
98
|
+
|----------|------|-------------|
|
|
99
|
+
| `serviceName` | `string` | Service name displayed in the GOV.UK header |
|
|
100
|
+
| `serviceHref` | `string` | Link for the service name (default: `/`) |
|
|
101
|
+
|
|
102
|
+
#### `themeConfig.govuk.navigation`
|
|
103
|
+
|
|
104
|
+
Array of top-level navigation items. Each item appears in the Service Navigation bar.
|
|
105
|
+
|
|
106
|
+
| Property | Type | Description |
|
|
107
|
+
|----------|------|-------------|
|
|
108
|
+
| `text` | `string` | Navigation link text |
|
|
109
|
+
| `href` | `string` | Base path for this section |
|
|
110
|
+
| `sidebar` | `array` | Optional sidebar items for this section |
|
|
111
|
+
|
|
112
|
+
Each `sidebar` item:
|
|
113
|
+
|
|
114
|
+
| Property | Type | Description |
|
|
115
|
+
|----------|------|-------------|
|
|
116
|
+
| `text` | `string` | Sidebar link text |
|
|
117
|
+
| `href` | `string` | Path relative to the parent navigation `href` |
|
|
118
|
+
| `items` | `array` | Optional nested sidebar items (one level of nesting) |
|
|
119
|
+
|
|
120
|
+
#### `themeConfig.govuk.phaseBanner`
|
|
121
|
+
|
|
122
|
+
| Property | Type | Description |
|
|
123
|
+
|----------|------|-------------|
|
|
124
|
+
| `phase` | `string` | Phase tag text (e.g. `'alpha'`, `'beta'`) |
|
|
125
|
+
| `text` | `string` | Banner body text (plain text, rendered as React children) |
|
|
126
|
+
| `feedbackHref` | `string` | Optional URL for a feedback link appended after the text |
|
|
127
|
+
|
|
128
|
+
#### `themeConfig.govuk.footer`
|
|
129
|
+
|
|
130
|
+
| Property | Type | Description |
|
|
131
|
+
|----------|------|-------------|
|
|
132
|
+
| `meta` | `array` | Array of `{ text, href }` objects rendered as footer meta links |
|
|
133
|
+
|
|
134
|
+
## Sidebar Configuration
|
|
135
|
+
|
|
136
|
+
The sidebar is configured through `themeConfig.govuk.navigation[].sidebar`, **not** through Docusaurus's built-in sidebar system. The Docusaurus `sidebars.js` file is still used by `plugin-content-docs` for route generation and doc ordering, but the visual sidebar is rendered by the GOV.UK theme.
|
|
137
|
+
|
|
138
|
+
The sidebar supports up to 3 levels:
|
|
139
|
+
1. **Level 1**: Service Navigation (top bar)
|
|
140
|
+
2. **Level 2**: Sidebar items
|
|
141
|
+
3. **Level 3**: Nested sidebar items (collapsible groups)
|
|
142
|
+
|
|
143
|
+
## Overriding Components
|
|
144
|
+
|
|
145
|
+
You can override any theme component by creating a file at the same path in your project's `src/theme/` directory. For example, to override the 404 page:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
src/theme/NotFound/Content/index.js
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Common components to override:
|
|
152
|
+
- `Layout` — the full page shell
|
|
153
|
+
- `NotFound/Content` — 404 page content
|
|
154
|
+
- `Homepage` — the default landing page
|
|
155
|
+
- `CodeBlock` — code block rendering
|
|
156
|
+
- `Heading` — heading elements
|
|
157
|
+
- `Admonition` — callout blocks
|
|
158
|
+
|
|
159
|
+
## Compatibility
|
|
160
|
+
|
|
161
|
+
- **Docusaurus**: ^3.0.0
|
|
162
|
+
- **React**: ^18.0.0 || ^19.0.0
|
|
163
|
+
- **Node.js**: 18+
|
package/index.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const CopyPlugin = require('copy-webpack-plugin');
|
|
4
|
+
|
|
5
|
+
module.exports = function themeGovuk(context, options) {
|
|
6
|
+
const themePath = path.resolve(__dirname, './src/theme');
|
|
7
|
+
const shimPath = path.resolve(__dirname, './src/lib/react-foundry-router-shim.js');
|
|
8
|
+
|
|
9
|
+
// Resolve govuk-frontend assets directory from this package's dependencies
|
|
10
|
+
const govukFrontendAssetsPath = path.dirname(
|
|
11
|
+
require.resolve('govuk-frontend/package.json')
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// The base URL for this Docusaurus site (e.g. '/interactive-map/')
|
|
15
|
+
const baseUrl = context.baseUrl || '/';
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
name: 'docusaurus-theme-govuk',
|
|
19
|
+
|
|
20
|
+
getThemePath() {
|
|
21
|
+
return './src/theme';
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
getPathsToWatch() {
|
|
25
|
+
return [
|
|
26
|
+
path.join(themePath, '**/*.js'),
|
|
27
|
+
path.resolve(__dirname, './src/css/**/*.{scss,css}'),
|
|
28
|
+
];
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
getClientModules() {
|
|
32
|
+
return [path.resolve(__dirname, './src/css/theme.scss')];
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
configureWebpack(config, isServer, utils) {
|
|
36
|
+
// Resolve React from the consumer (siteDir) to avoid dual-instance issues.
|
|
37
|
+
// The theme ships its own node_modules/react via `file:` linking,
|
|
38
|
+
// so we must force all React imports to the consumer's single copy.
|
|
39
|
+
const siteDir = context.siteDir;
|
|
40
|
+
|
|
41
|
+
// Helper: resolve a package from the consumer's siteDir.
|
|
42
|
+
// Uses require.resolve with paths so it follows Node's resolution
|
|
43
|
+
// (handles hoisted AND nested node_modules like @docusaurus/core/node_modules/react-router-dom).
|
|
44
|
+
function resolveFromSite(pkg) {
|
|
45
|
+
try {
|
|
46
|
+
return path.dirname(
|
|
47
|
+
require.resolve(`${pkg}/package.json`, { paths: [siteDir] })
|
|
48
|
+
);
|
|
49
|
+
} catch {
|
|
50
|
+
// Fallback: try resolving from @docusaurus/core (where react-router is nested in 3.9.x)
|
|
51
|
+
const docuCorePath = path.dirname(
|
|
52
|
+
require.resolve('@docusaurus/core/package.json', { paths: [siteDir] })
|
|
53
|
+
);
|
|
54
|
+
return path.dirname(
|
|
55
|
+
require.resolve(`${pkg}/package.json`, { paths: [docuCorePath] })
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
resolve: {
|
|
62
|
+
extensions: ['.mjs', '.js', '.jsx', '.json', '.scss'],
|
|
63
|
+
fullySpecified: false,
|
|
64
|
+
alias: {
|
|
65
|
+
// Deduplicate React — always use the consumer's copy
|
|
66
|
+
'react': resolveFromSite('react'),
|
|
67
|
+
'react-dom': resolveFromSite('react-dom'),
|
|
68
|
+
'react/jsx-runtime': path.join(resolveFromSite('react'), 'jsx-runtime'),
|
|
69
|
+
'react/jsx-dev-runtime': path.join(resolveFromSite('react'), 'jsx-dev-runtime'),
|
|
70
|
+
// Deduplicate React Router — always use the consumer's copy
|
|
71
|
+
// (Docusaurus creates the Router context with its copy; we must read from the same copy)
|
|
72
|
+
'react-router': resolveFromSite('react-router'),
|
|
73
|
+
'react-router-dom': resolveFromSite('react-router-dom'),
|
|
74
|
+
'react-router-config': resolveFromSite('react-router-config'),
|
|
75
|
+
// Ensure @mdx-js/react resolves from the theme's node_modules,
|
|
76
|
+
// not the consumer's (which may not have it installed).
|
|
77
|
+
'@mdx-js/react': path.resolve(
|
|
78
|
+
__dirname,
|
|
79
|
+
'node_modules/@mdx-js/react'
|
|
80
|
+
),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
plugins: [
|
|
84
|
+
// Copy GOV.UK assets (fonts, images, manifest, rebrand) to the build
|
|
85
|
+
// output so they can be served statically. The SCSS outputs url()
|
|
86
|
+
// references via $govuk-assets-path pointing to /assets/; we must
|
|
87
|
+
// ensure the actual files exist at that path in the build.
|
|
88
|
+
new CopyPlugin({
|
|
89
|
+
patterns: [
|
|
90
|
+
{
|
|
91
|
+
from: path.join(govukFrontendAssetsPath, 'dist/govuk/assets'),
|
|
92
|
+
to: path.resolve(config.output.path || 'build', 'assets'),
|
|
93
|
+
noErrorOnMissing: true,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
}),
|
|
97
|
+
// Shim @react-foundry/router to bridge React Router v5 (Docusaurus) to v6 API
|
|
98
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
99
|
+
/@react-foundry\/router/,
|
|
100
|
+
shimPath
|
|
101
|
+
),
|
|
102
|
+
// Redirect @react-foundry packages to their CJS entry points.
|
|
103
|
+
// The .mjs entry points use extensionless re-exports (e.g. export * from './classes')
|
|
104
|
+
// which fail under webpack's fullySpecified enforcement for .mjs files.
|
|
105
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
106
|
+
/^@react-foundry\/component-helpers$/,
|
|
107
|
+
require.resolve('@react-foundry/component-helpers')
|
|
108
|
+
),
|
|
109
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
110
|
+
/^@react-foundry\/client-component-helpers$/,
|
|
111
|
+
require.resolve('@react-foundry/client-component-helpers')
|
|
112
|
+
),
|
|
113
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
114
|
+
/^@react-foundry\/uri$/,
|
|
115
|
+
require.resolve('@react-foundry/uri')
|
|
116
|
+
),
|
|
117
|
+
// Resolve asset paths from @not-govuk packages to govuk-frontend
|
|
118
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
119
|
+
/^\.\.\/\.\.\/assets\/(images|fonts)\//,
|
|
120
|
+
(resource) => {
|
|
121
|
+
const assetType = resource.request.includes('/images/') ? 'images' : 'fonts';
|
|
122
|
+
const fileName = resource.request.split('/').pop();
|
|
123
|
+
resource.request = path.join(
|
|
124
|
+
govukFrontendAssetsPath,
|
|
125
|
+
`dist/govuk/assets/${assetType}/${fileName}`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
// Resolve govuk-frontend font paths from @not-govuk/page
|
|
130
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
131
|
+
/^\.\.\/\.\.\/node_modules\/govuk-frontend\/dist\/govuk\/assets\/(fonts|images)\//,
|
|
132
|
+
(resource) => {
|
|
133
|
+
const assetType = resource.request.includes('/fonts/') ? 'fonts' : 'images';
|
|
134
|
+
const fileName = resource.request.split('/').pop();
|
|
135
|
+
resource.request = path.join(
|
|
136
|
+
govukFrontendAssetsPath,
|
|
137
|
+
`dist/govuk/assets/${assetType}/${fileName}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
// Null out the font SCSS wrappers from @not-govuk/page.
|
|
142
|
+
// GovUKPage.scss imports gds-transport.css, and NotGovUKPage.scss
|
|
143
|
+
// imports roboto.css. These contain @font-face rules with relative
|
|
144
|
+
// URLs that, when inlined by sass and processed by css-loader,
|
|
145
|
+
// produce hashed font assets that are corrupt (OTS parsing errors).
|
|
146
|
+
// The SCSS pipeline (govuk-frontend _font-faces.scss) already
|
|
147
|
+
// provides working @font-face declarations for GDS Transport with
|
|
148
|
+
// the correct baseUrl-prefixed URLs, so these are redundant.
|
|
149
|
+
// Match both the relative request (../assets/X.scss) from JS files
|
|
150
|
+
// and any absolute-path form that webpack may resolve.
|
|
151
|
+
new webpack.NormalModuleReplacementPlugin(
|
|
152
|
+
/\/?(\.\.\/)?assets\/(GovUKPage|NotGovUKPage)\.scss$/,
|
|
153
|
+
path.resolve(__dirname, 'src/lib/empty-module.js')
|
|
154
|
+
),
|
|
155
|
+
],
|
|
156
|
+
module: {
|
|
157
|
+
rules: [
|
|
158
|
+
{
|
|
159
|
+
test: /\.m?js$/,
|
|
160
|
+
resolve: {
|
|
161
|
+
fullySpecified: false,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
test: /\.scss$/,
|
|
166
|
+
use: [
|
|
167
|
+
'style-loader',
|
|
168
|
+
{
|
|
169
|
+
loader: 'css-loader',
|
|
170
|
+
options: {
|
|
171
|
+
importLoaders: 2,
|
|
172
|
+
url: {
|
|
173
|
+
filter: (url) => {
|
|
174
|
+
// Don't process absolute asset URLs — they are served as static files.
|
|
175
|
+
// Matches both /assets/ and /<baseUrl>assets/ patterns.
|
|
176
|
+
if (url.startsWith('/assets/') || url.startsWith(baseUrl + 'assets/')) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
'postcss-loader',
|
|
185
|
+
{
|
|
186
|
+
loader: 'sass-loader',
|
|
187
|
+
options: {
|
|
188
|
+
implementation: require('sass'),
|
|
189
|
+
// Override GOV.UK asset path to include the Docusaurus baseUrl.
|
|
190
|
+
// The default '../../assets/' produces URLs without baseUrl,
|
|
191
|
+
// causing 404s when baseUrl is not '/'.
|
|
192
|
+
// Only prepend for SCSS/Sass files — plain CSS can't use Sass variables.
|
|
193
|
+
additionalData: (content, loaderContext) => {
|
|
194
|
+
if (/\.scss$|\.sass$/.test(loaderContext.resourcePath)) {
|
|
195
|
+
return `$govuk-assets-path: '${baseUrl}assets/';\n` + content;
|
|
196
|
+
}
|
|
197
|
+
return content;
|
|
198
|
+
},
|
|
199
|
+
sassOptions: {
|
|
200
|
+
includePaths: [
|
|
201
|
+
path.resolve(__dirname, 'node_modules'),
|
|
202
|
+
],
|
|
203
|
+
quietDeps: true,
|
|
204
|
+
silenceDeprecations: ['import', 'if-function'],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@defra/docusaurus-theme-govuk",
|
|
3
|
+
"version": "0.0.1-alpha",
|
|
4
|
+
"description": "A Docusaurus theme implementing the GOV.UK Design System for consistent, accessible documentation sites",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"src/"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"docusaurus",
|
|
13
|
+
"docusaurus-theme",
|
|
14
|
+
"govuk",
|
|
15
|
+
"gov.uk",
|
|
16
|
+
"design-system",
|
|
17
|
+
"documentation"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/DEFRA/docusaurus-theme-govuk"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@docusaurus/core": "^3.0.0",
|
|
25
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
26
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@mdx-js/react": "^3.0.0",
|
|
30
|
+
"@not-govuk/simple-components": "^0.17.3",
|
|
31
|
+
"clsx": "^2.0.0",
|
|
32
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
33
|
+
"css-loader": "^7.1.0",
|
|
34
|
+
"govuk-frontend": "^5.14.0",
|
|
35
|
+
"postcss-loader": "^8.2.0",
|
|
36
|
+
"prism-react-renderer": "^2.3.0",
|
|
37
|
+
"sass": "^1.97.0",
|
|
38
|
+
"sass-loader": "^16.0.0",
|
|
39
|
+
"style-loader": "^4.0.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Component styles extracted from inline JS styles
|
|
2
|
+
// to allow consumer CSS overrides and reduce HTML payload.
|
|
3
|
+
|
|
4
|
+
// Sidebar layout
|
|
5
|
+
.app-layout-sidebar {
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 2rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.app-layout-sidebar__nav {
|
|
11
|
+
width: 250px;
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.app-layout-sidebar__content {
|
|
16
|
+
flex: 1;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Code block
|
|
21
|
+
.app-code-block {
|
|
22
|
+
position: relative;
|
|
23
|
+
margin-bottom: 1.25rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.app-code-block__title {
|
|
27
|
+
padding: 0.5rem 1rem;
|
|
28
|
+
background: #f3f2f1;
|
|
29
|
+
border-bottom: 1px solid #b1b4b6;
|
|
30
|
+
font-size: 0.875rem;
|
|
31
|
+
font-weight: 700;
|
|
32
|
+
font-family: 'GDS Transport', arial, sans-serif;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.app-code-block__pre {
|
|
36
|
+
padding: 1rem;
|
|
37
|
+
border-radius: 0;
|
|
38
|
+
overflow: auto;
|
|
39
|
+
font-size: 0.875rem;
|
|
40
|
+
line-height: 1.6;
|
|
41
|
+
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
|
|
42
|
+
position: relative;
|
|
43
|
+
border: 1px solid #b1b4b6;
|
|
44
|
+
margin: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.app-code-block__copy {
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: 0.5rem;
|
|
50
|
+
right: 0.5rem;
|
|
51
|
+
padding: 0.25rem 0.75rem;
|
|
52
|
+
font-size: 0.8125rem;
|
|
53
|
+
border: 1px solid #b1b4b6;
|
|
54
|
+
border-radius: 0;
|
|
55
|
+
background: #f3f2f1;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
font-family: 'GDS Transport', arial, sans-serif;
|
|
58
|
+
color: #0b0c0c;
|
|
59
|
+
|
|
60
|
+
&:hover {
|
|
61
|
+
background: #dbdad9;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Heading anchor link
|
|
66
|
+
.app-heading-anchor {
|
|
67
|
+
margin-left: 0.5rem;
|
|
68
|
+
text-decoration: none;
|
|
69
|
+
opacity: 0.4;
|
|
70
|
+
font-size: 0.8em;
|
|
71
|
+
|
|
72
|
+
&:hover {
|
|
73
|
+
opacity: 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Pagination
|
|
78
|
+
.app-pagination__container {
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.app-pagination__next {
|
|
84
|
+
text-align: right;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Secondary text colour (matches govuk-frontend $govuk-secondary-text-colour)
|
|
88
|
+
.app-text-secondary {
|
|
89
|
+
color: #505a5f;
|
|
90
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* Hide Docusaurus breadcrumbs (defensive - in case classic elements leak through) */
|
|
2
|
+
.theme-doc-breadcrumbs {
|
|
3
|
+
display: none !important;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/* Hide Docusaurus sidebar (we use GOV.UK NavigationMenu instead) */
|
|
7
|
+
.theme-doc-sidebar-container {
|
|
8
|
+
display: none !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Make doc content full width */
|
|
12
|
+
[class*='docMainContainer'] {
|
|
13
|
+
max-width: 100% !important;
|
|
14
|
+
flex: 1 !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.container {
|
|
18
|
+
max-width: 100%;
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Import GOV.UK Frontend base (settings, tools, helpers) and core (placeholders)
|
|
2
|
+
@import "govuk-frontend/dist/govuk/base";
|
|
3
|
+
@import "govuk-frontend/dist/govuk/core";
|
|
4
|
+
|
|
5
|
+
.app-prose-scope {
|
|
6
|
+
// Headings
|
|
7
|
+
h1 {
|
|
8
|
+
@extend %govuk-heading-xl;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
h2 {
|
|
12
|
+
@extend %govuk-heading-l;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
h3 {
|
|
16
|
+
@extend %govuk-heading-m;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
h4 {
|
|
20
|
+
@extend %govuk-heading-s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Body text
|
|
24
|
+
p {
|
|
25
|
+
@extend %govuk-body-m;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Bold text
|
|
29
|
+
strong,
|
|
30
|
+
b {
|
|
31
|
+
font-weight: 700;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Lists
|
|
35
|
+
ul,
|
|
36
|
+
ol {
|
|
37
|
+
@extend %govuk-list;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ol {
|
|
41
|
+
@extend %govuk-list--number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ul {
|
|
45
|
+
@extend %govuk-list--bullet;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Links
|
|
49
|
+
a {
|
|
50
|
+
@extend %govuk-link;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Section breaks
|
|
54
|
+
hr {
|
|
55
|
+
@extend %govuk-section-break;
|
|
56
|
+
@extend %govuk-section-break--visible;
|
|
57
|
+
@extend %govuk-section-break--xl;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Import doc overrides to hide Docusaurus built-in elements */
|
|
2
|
+
@import './doc-overrides.css';
|
|
3
|
+
|
|
4
|
+
/* Import prose scope for markdown content styling */
|
|
5
|
+
@import './prose-scope.scss';
|
|
6
|
+
|
|
7
|
+
/* Import component styles */
|
|
8
|
+
@import './components.scss';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Set the default font on the body so that ALL elements
|
|
12
|
+
* (header, footer, service-nav, etc.) inherit GDS Transport.
|
|
13
|
+
* The prose-scope only covers content inside .app-prose-scope;
|
|
14
|
+
* without this, outer chrome inherits the browser default serif.
|
|
15
|
+
*/
|
|
16
|
+
body {
|
|
17
|
+
font-family: 'GDS Transport', arial, sans-serif;
|
|
18
|
+
}
|