Skip to content

Conversation

@theartcher
Copy link
Contributor

Related issue #33

This PR proposes to do the following;

  • Add .env variable support, with a default fallback to /.
  • Remove old 'TODO' comment from config file.
  • Add docs regarding config files.
  • Update code standards regarding TODOs and FUTURE_WORKs.
  • Add dotenv package.
  • Fix navigator not using correct base URL.
  • Add initial version of deployment docs.

…nore, update config and navigator to use baseURL
@theartcher theartcher self-assigned this Dec 13, 2025
@theartcher theartcher added the bug Something isn't working label Dec 13, 2025
Copilot AI review requested due to automatic review settings December 13, 2025 11:43
@theartcher theartcher added documentation Improvements or additions to documentation page Has changes relating to a page's content. labels Dec 13, 2025
@theartcher theartcher merged commit 23d3f8c into main Dec 13, 2025
5 checks passed
@theartcher theartcher deleted the bugfix/#33/navigator-page-linking-broken branch December 13, 2025 11:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds environment variable support for configuring the base URL of the Docusaurus site, addressing the need for flexible deployment configurations. The implementation allows the site to be deployed under different base paths (e.g., GitHub Pages repository paths) by reading from a BASE_URL environment variable with a fallback to the root path /.

Key changes:

  • Add .env file support using the dotenv package for runtime configuration
  • Refactor PatternResult component to use the configurable base URL from Docusaurus context instead of hardcoded values
  • Update documentation with deployment guidelines and clarify coding standards around TODO/FUTURE_WORK comments

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/navigator/PatternResult.tsx Updated to retrieve base URL from Docusaurus customFields instead of using hardcoded value
package.json Added dotenv dependency for environment variable support
package-lock.json Added lockfile entries for dotenv package and updated version to 1.0.0
docusaurus.config.ts Imported dotenv, read BASE_URL from environment, and passed it through customFields for client-side access
README.md Added deployment section with .env configuration instructions and updated coding standard about TODO/FUTURE_WORK comments
.gitignore Added .env to prevent committing environment variables

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.
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.
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.
<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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation page Has changes relating to a page's content.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant