Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subpage for the stories #51

Closed
marekbrze opened this issue Sep 24, 2024 · 5 comments
Closed

Subpage for the stories #51

marekbrze opened this issue Sep 24, 2024 · 5 comments

Comments

@marekbrze
Copy link

Hi!

I really like your project!

It would be great to be able to add this to the existing project and generate Astrobook on the selected subpage - like "example.com/astrobook".

@ocavue
Copy link
Owner

ocavue commented Sep 26, 2024

Hi. You can implement this by adding base: '/astrobook' to your astro.config.mjs file. Check Astro's docs for more information.

@ocavue ocavue closed this as completed Sep 26, 2024
@marekbrze
Copy link
Author

@ocavue but isn't this option for the WHOLE Astro project?

I was thinking about setting path for the integration itself and deciding where it should display.

My perfect use case is:

  • I have an existing blog astro project
  • I add "Astrobook" to this existing project
  • I set "/astrobook" for the Astrobook integration and "devOnly" flag to true
  • When I run npm run dev I have my Astrobook shown on the /astrbook path as a help when developing components
  • When I build the blog project the Astrobook shouldn't be generated

@ocavue
Copy link
Owner

ocavue commented Sep 26, 2024

I see. You want to integrate astrobook into an existing astro project. Let me reopen this issue.

@ocavue ocavue reopened this Sep 26, 2024
marcioscf pushed a commit to marcioscf/astrobook that referenced this issue Oct 15, 2024
with the new docsUrl configuration, you can integrate in existing astro projects with a different sub route.
@ocavue
Copy link
Owner

ocavue commented Oct 17, 2024

astrobook@0.5.0 adds a new subpath option, which allow you to use Astrobook in an existing Astro project.

// astro.config.ts

import { defineConfig } from 'astro/config'
import astrobook from 'astrobook'

export default defineConfig({
  integrations: astrobook({ subpath: "/astrobook" })
})

When I run npm run dev I have my Astrobook shown on the /astrbook path as a help when developing components
When I build the blog project the Astrobook shouldn't be generated

You can use process.env.NODE_ENV in your astro.config.ts:

// astro.config.ts

import svelte from '@astrojs/svelte'
import { defineConfig } from 'astro/config'
import astrobook from 'astrobook'

console.log('process.env.NODE_ENV', process.env.NODE_ENV)

const integrations = [svelte()]

if (process.env.NODE_ENV === 'development') {
  integrations.push(astrobook())
}

export default defineConfig({
  integrations,
})

@ocavue ocavue closed this as completed Oct 17, 2024
@marekbrze
Copy link
Author

@ocavue Awesome! I will test it today ❤️🙌

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

No branches or pull requests

2 participants