When I run my site in dev, my TypeItJS script runs no problem. When it's built, it doesn't. Any ideas why? I can't figure it out.
https://github.com/0niSec/astro-security-blog/blob/master/src%2Fpages%2Findex.astro
97 messages · Page 1 of 1 (latest)
When I run my site in dev, my TypeItJS script runs no problem. When it's built, it doesn't. Any ideas why? I can't figure it out.
https://github.com/0niSec/astro-security-blog/blob/master/src%2Fpages%2Findex.astro
`<script is:inline src="https://identity.netlify.com/v1/netlify-identity-widget.js"
</script>`
x D
without it astro is hoisting ( moving it all into one file if the file isnt too big )
and its creating an error which basically stopping the whole script
in dev the script tags raent optimized yet
in basehead
try adding the is:inline
then to see the production build locally you can pnpm build && pnpm preview
that stops running it in dev now lol
well thats crazy
<script is:inline>
import TypeIt from "typeit";
new TypeIt("#header", {
strings: "鬼 0niSec",
loop: true,
})
.go()
.pause(1500);
</script>
this script
Just so im clear lol
noo
in basehead put it on line 18
you can import from nodemodules in an inline script because astro wont process it btw
cant***
🎉
haha nah that is a very niche error
not an idiot at all that wouldve stumped a lot of people
the error in console about the widget was a hint though
The resource at “http://localhost:4321/fonts/firacode-regular.ttf” preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly.
what mean this
downloadable font: no supported format found (font-family: "Fira Code" style:normal weight:400 stretch:100 src index:1) source: (end of source list)
and that
There's a CORS error originating from the hoisted.js file. Pretty sure that's the file containing the TypeIt code. My guess would be that's the reason
ive not seen these errors but just going by the error text im assuming youre not actually using that font
It's being used and rendered so it def is
should make a new support thread tbh lol
I'm just figuring out CORS and XSS and whatnot -- any idea how to fix?
so others can help there because ive never used fonts
for SSG
that error was coming from not having is:inline
ahhhh
identity widget needed to be coming from the root page not from a different file
Sorry, I just noticed you were already discussing the cors error 😅
first hit on google is Astro related haha. Oliver's solution is suggested there as well https://answers.netlify.com/t/cors-error-with-identity-widget-on-deployed-website/75484
Hi there, I’ve recently built a portfolio website with Astro and I’ve implemented Netlify CMS using the custom configuration mentioned on the docs and it works as intented. However, I’m running into an issue where the identity widget is displaying a CORS issue in the console: Access to script at 'https://identity.netlify.com/v1/netlify-identit...
This warning is just a reminder that you shouldn't preload everything on your page, just the necessary stuff. In this case the font wasn't used immediately so the browser is warning you that you might not want to preload it
That's prefetch right?
It's called preload on the link tag, but same thing
hm, still getting it after setting prefetch to just hover
weird
ill fix it later
not doing that on this branch
Oh sorry, it's not the astro prefetching
It's this tag in your head <link rel="preload" href="/fonts/firacode-regular.ttf" as="font" type="font/ttf" crossorigin="">
That being said I'm not sure why it's complaining because it seems to be used in the style tag in the head 🤷♂️ These warnings can be a bit mysterious sometimes
Okay maybe I didn't fix it lmao
Do I import the module in BaseHead in the script?
wym sorry
It still won't work in prd when built lol
The TypeIt script
So I did that just now (didn't push) and it still isn't working lol
i pulled and tried it
seems working
im saying the netlify indeitfy script on line 30
the line i linked
yes i know
remember because when that one doesnt have is inline
it creates an error in browser
Import declarations may only occur at top level in browser
So where do I import lol
no
on line 30
add is:inline
just like in the picture
to the netlify indentify script
Yep isn't working locally
---
// Import the global.css file here so that it is included on
// all pages through the use of the <BaseHead /> component.
import "../styles/global.css";
interface Props {
title: string;
description: string;
image?: string;
}
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const { title, description, image = "/blog-placeholder-1.jpg" } = Astro.props;
---
<!-- TypeIt JS -->
<script is:inline>
import TypeIt from "typeit";
new TypeIt("#header", {
strings: "鬼 0niSec",
loop: true,
})
.go()
.pause(1500);
</script>
<!-- Netlify Identify -->
<script
src="https://identity.netlify.com/v1/netlify-identity-widget.js"
is:inline></script>
<!-- Global Metadata -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<!-- Font preloads -->
<link
rel="preload"
href="/fonts/firacode-regular.ttf"
as="font"
type="font/ttf"
crossorigin
/>
<!-- Canonical URL -->
<link rel="canonical" href={canonicalURL} />
<!-- Primary Meta Tags -->
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={new URL(image, Astro.url)} />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={Astro.url} />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
<meta property="twitter:image" content={new URL(image, Astro.url)} />
ohhhh