Skip to content

feat: add support for Astro base path#621

Open
sirlisko wants to merge 3 commits intosatnaing:mainfrom
sirlisko:feat/support-base
Open

feat: add support for Astro base path#621
sirlisko wants to merge 3 commits intosatnaing:mainfrom
sirlisko:feat/support-base

Conversation

@sirlisko
Copy link

Description

Adds support for Astro's base configuration option, allowing AstroPaper to be served under a sub-path (e.g. domain.com/blog).

A new SITE.base field in src/config.ts is the single place to configure this. It is passed to Astro's base option in astro.config.ts, which exposes import.meta.env.BASE_URL throughout the codebase.

All internal links in components, layouts, and pages now use BASE_URL instead of hardcoded paths.

Types of changes

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update (if none of the other choices apply)
  • Others (any other types not listed above)

Checklist

  • I have read the [Contributing Guide](https://github.com/satnaing/astro-p
    aper/blob/main/.github/CONTRIBUTING.md)
  • I have added the necessary documentation (if appropriate)
  • Breaking Change (fix or feature that would cause existing functionality
    to not work as expected)

Further comments

To use a sub-path, set SITE.base in src/config.ts:

export const SITE = {
  base: "/blog/", // site will be served at domain.com/blog
  ...
}

Leave it unset or as "/" for a root deployment, behaviour is unchanged from before.

Related Issue

Closes: #493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Github Pages support via base property.

1 participant