Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment variables
.env
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
- [Local Development](#local-development)
- [Linting](#linting)
- [Build and serve](#build-and-serve)
- [Deployment](#deployment)
- [GitHub Pages](#github-pages)
- [Docker Image](#docker-image)
- [Contributing](#contributing)

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
Expand All @@ -24,6 +27,7 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati
10. Each page is built using the [template](/template.mdx) (validated by `npm run lint:mdx`).
11. Custom components should not implement their own title, they should use the correct heading (#) level in the page itself to ensure proper url based linking.
12. Images need to have padding applied around them, optimally `2rem`.
13. Code has no 'TODO' blocks, only a 'FUTURE_WORK' block may be present with a reference to an issue or task.

## Installation

Expand Down Expand Up @@ -65,6 +69,25 @@ And then to serve the newly created build, simply run.
npm run serve
```

## Deployment

To deploy the website, there are multiple options available depending on your hosting preferences. But first you should create a `.env` file in the root directory of the project with the following content:

```env
# This value MUST start and end with a slash '/', unless it's the root '/'.
BASE_URL=''
```

This step is only necessary when you want to differ from the default `baseUrl` value of `/`. This is particularly useful when deploying to GitHub Pages under a repository, e.g., `https://username.github.io/repository-name/`, where the `BASE_URL` should be set to `/repository-name/`. See the [Docusaurus docs](https://docusaurus.io/docs/api/docusaurus-config#baseUrl) for more information
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a period at the end of the sentence. The sentence should end with proper punctuation.

Suggested change
This step is only necessary when you want to differ from the default `baseUrl` value of `/`. This is particularly useful when deploying to GitHub Pages under a repository, e.g., `https://username.github.io/repository-name/`, where the `BASE_URL` should be set to `/repository-name/`. See the [Docusaurus docs](https://docusaurus.io/docs/api/docusaurus-config#baseUrl) for more information
This step is only necessary when you want to differ from the default `baseUrl` value of `/`. This is particularly useful when deploying to GitHub Pages under a repository, e.g., `https://username.github.io/repository-name/`, where the `BASE_URL` should be set to `/repository-name/`. See the [Docusaurus docs](https://docusaurus.io/docs/api/docusaurus-config#baseUrl) for more information.

Copilot uses AI. Check for mistakes.

### GitHub Pages

T.B.A

### Docker Image

T.B.A

## Contributing

Would you like to propose changes to the pattern-wiki? Then feel free to create a pull request in this repository. Make sure that your PR follows the standards as set in the [coding standards](#coding-standards). These standards ensure that the wiki is of high quality and that both the users and developers can find the right information quickly. The steps to work on an issue or task are as follows:
Expand Down
10 changes: 8 additions & 2 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { themes as prismThemes } from "prism-react-renderer";
import type { Config } from "@docusaurus/types";
import type * as Preset from "@docusaurus/preset-classic";
import packageJson from "./package.json";
import "dotenv/config";

const baseUrlOrDefault = process.env.BASE_URL || "/";

//todo enable search
const config: Config = {
title: "Design Pattern Pedia",
tagline: "Practicing Patterns Made Plain and Practical",
Expand All @@ -12,7 +14,11 @@ const config: Config = {
v4: true,
},
url: "https://your-docusaurus-site.example.com",
baseUrl: "/",
baseUrl: baseUrlOrDefault,
customFields: {
// We need to pass this directly as process.env is not available in the client bundle. But we do need this variable in the client bundle.
baseUrl: baseUrlOrDefault,
},
organizationName: "S7-OpenLearning-Individual",
projectName: "DesignPatternPedia",
onBrokenLinks: "throw",
Expand Down
17 changes: 15 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@easyops-cn/docusaurus-search-local": "^0.52.1",
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"dotenv": "^17.2.3",
"prism-react-renderer": "^2.3.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
12 changes: 11 additions & 1 deletion src/components/navigator/PatternResult.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import styles from "./navigator.module.css";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";

const baseURL = "/DesignPatternPedia/docs";
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded baseURL constant is now unused and should be removed. The component now retrieves the base URL from customFields instead.

Suggested change
const baseURL = "/DesignPatternPedia/docs";

Copilot uses AI. Check for mistakes.

Expand All @@ -16,14 +17,23 @@ const PatternResult: React.FC<PatternResultProps> = ({
path,
onReset,
}) => {
const {
siteConfig: { customFields },
} = useDocusaurusContext();

const baseUrlOrDefault = customFields.baseUrl || "/";
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type assertion for customFields.baseUrl should be added since customFields is typed as Record<string, unknown> in Docusaurus. Consider accessing it as (customFields.baseUrl as string | undefined) to ensure type safety.

Suggested change
const baseUrlOrDefault = customFields.baseUrl || "/";
const baseUrlOrDefault = (customFields.baseUrl as string | undefined) || "/";

Copilot uses AI. Check for mistakes.

return (
<>
<div className={styles.divider} />
<div className={styles.patternResult}>
<h2>{name}</h2>
<p>{description}</p>
<div className={styles.resultButtons}>
<a href={`${baseURL}/${path}`} className="button button--primary">
<a
href={`${baseUrlOrDefault}docs/${path}`}
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL construction logic may produce double slashes when baseUrlOrDefault is "/" (the default). For example, if baseUrlOrDefault is "/", the href will be "/docs/path", which is correct. However, if baseUrlOrDefault is "/repository-name/", the href will be "/repository-name/docs/path", which is also correct. But if baseUrlOrDefault doesn't end with a slash (which violates the documentation), this could produce incorrect URLs. Consider adding validation or a more robust URL joining mechanism.

Copilot uses AI. Check for mistakes.
className="button button--primary"
>
Learn More
</a>
<button
Expand Down