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

Add astro tutorial #2098

Merged

Conversation

b-d-m-p
Copy link
Contributor

@b-d-m-p b-d-m-p commented Jul 2, 2024

This is a bare-bones Astro explanation of steps to add Shoelace to Astro.

I am sorry for not opening an issue like the community guidelines say to, I just thought as it was a documentation addition there was no issue to write about. If you'd like me to make an issue first, let me know and I will do that. Maybe adding an Astro tutorial is something you're not sure you want to do, but I had chatted with @KonnorRogers and he said he was working on something, so maybe this can help.

The format is based on the Shoelace NextJS tutorial.

Some background information... I had opened a discussion on on using Astro best practices and due to issues I was having, I thought that Astro/Shoelace with Astro's view transitions required a different set up than this bare-bones version, but while making this doc, I made a test project and added view transitions and it works fine, which is great for general users. There must be something wrong with my project.

Let me know if there's any changes I should make.

Cheers

Copy link

vercel bot commented Jul 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
shoelace ✅ Ready (Inspect) Visit Preview Jul 4, 2024 5:55am

@b-d-m-p
Copy link
Contributor Author

b-d-m-p commented Jul 2, 2024

I made this starter kit, which demos the setup in the tutorial. https://github.com/b-d-m-p/astro-shoelace-starter-kit-blog

@claviska
Copy link
Member

claviska commented Jul 2, 2024

Thanks for this! We probably want to add a link in the Tutorials section of the sidebar.

@KonnorRogers I'll defer this one to you, since you have more experience here.

@b-d-m-p
Copy link
Contributor Author

b-d-m-p commented Jul 2, 2024

Oh, I thought the sidebar was auto generated from the files in the folder. If it's manual, I'll add it to the PR.

@b-d-m-p
Copy link
Contributor Author

b-d-m-p commented Jul 2, 2024

It's in there now.

@b2m9
Copy link

b2m9 commented Jul 3, 2024

After I just banged my head against this: can we mention somewhere that SSR is not supported for Shoelace at the moment - hence the script statements on the client.

@KonnorRogers
Copy link
Collaborator

After I just banged my head against this: can we mention somewhere that SSR is not supported for Shoelace at the moment - hence the script statements on the client.

I haven't had a chance to actually check if it works, but the Lit SSR module shims the DOM.

https://docs.astro.build/en/guides/integrations-guide/lit/

I know for a fact some components will not render as expected with SSR, and I dont know if any of them will fail with the Lit SSR module

Copy link
Collaborator

@KonnorRogers KonnorRogers left a comment

Choose a reason for hiding this comment

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

I ended up making my own Astro setup here and testing out the docs you had and added some suggestions

https://github.com/KonnorRogers/shoelace-astro

My setup was as follows:

npm create astro@latest

[dir]: Where should we create your new project?
         ./shoelace-astro-2
         
  tmpl   How would you like to start your new project?
         ● Include sample files (recommended)
         ○ Use blog template 
         ○ Empty          
 
    ts   Do you plan to write TypeScript?
         ● Yes  ○ No 
         
      use   How strict should TypeScript be?
         ● Strict (recommended)
         ○ Strictest 
         ○ Relaxed 
         
     deps   Install dependencies? (recommended)
         ● Yes  ○ No 


   git   Initialize a new git repository? (optional)
         ● Yes  ○ No 

docs/pages/tutorials/integrating-with-astro.md Outdated Show resolved Hide resolved
docs/pages/tutorials/integrating-with-astro.md Outdated Show resolved Hide resolved
docs/pages/tutorials/integrating-with-astro.md Outdated Show resolved Hide resolved
docs/pages/tutorials/integrating-with-astro.md Outdated Show resolved Hide resolved
docs/pages/tutorials/integrating-with-astro.md Outdated Show resolved Hide resolved
@b2m9
Copy link

b2m9 commented Jul 3, 2024

I haven't had a chance to actually check if it works, but the Lit SSR module shims the DOM.

Here's a Stackblitz environment for an Astro/Lit integration. Shoelace doesn't fail because of lit-labs/ssr, it seems to fail because it is trying to access the DOM when it's not available (e.g. MutationObserver is not defined). Hence the workaround in the tutorial to load it on the client.

@KonnorRogers
Copy link
Collaborator

KonnorRogers commented Jul 3, 2024

I haven't had a chance to actually check if it works, but the Lit SSR module shims the DOM.

Here's a Stackblitz environment for an Astro/Lit integration. Shoelace doesn't fail because of lit-labs/ssr, it seems to fail because it is trying to access the DOM when it's not available (e.g. MutationObserver is not defined). Hence the workaround in the tutorial to load it on the client.

Yea there's going to be a number of components that need to be modified to work with Lit's SSR, I'm working on it, but its going to take some time. The Lit SSR module seems to do a very minimal DOM shim only for pieces required for rendering and not for trying to shim the entire DOM.

b-d-m-p and others added 4 commits July 4, 2024 14:44
Move import into index

Co-authored-by: Konnor Rogers <[email protected]>
Remove setBasePath from frontmatter imports

Co-authored-by: Konnor Rogers <[email protected]>
Add ssr & client scripts section

Co-authored-by: Konnor Rogers <[email protected]>
add rollup-plugin-copy to npm install command

Co-authored-by: Konnor Rogers <[email protected]>
b-d-m-p and others added 2 commits July 4, 2024 14:50
Move setBasePath to script tag

Co-authored-by: Konnor Rogers <[email protected]>
Add explanation for addition of rollup-plugin-copy

Co-authored-by: Konnor Rogers <[email protected]>
@b-d-m-p
Copy link
Contributor Author

b-d-m-p commented Jul 4, 2024

@KonnorRogers all your additions are in there now. Thanks! Anything else needed?

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.

4 participants