Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
gioboa committed Dec 21, 2024
1 parent 5ef85cf commit 7786db1
Show file tree
Hide file tree
Showing 40 changed files with 71 additions and 145 deletions.
10 changes: 5 additions & 5 deletions docs/src/components/Aside/Aside.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { component$ } from "@qwik.dev/core";
import { Link, useContent } from "@qwik.dev/router";
import { useContent } from "@qwik.dev/router";

export const Aside = component$(() => {
const { menu } = useContent();
Expand All @@ -13,20 +13,20 @@ export const Aside = component$(() => {
return (
<ul key={idx} class="mb-6">
<li>
<Link
<a
class="mb-2 block rounded bg-blue-700 px-4 py-1 text-base font-bold uppercase text-white no-underline"
href={href}
>
{title}
</Link>
</a>
{(items || []).map(({ text, href }, idx) => (
<ul key={idx}>
<li class="py-1 text-black dark:text-white">
<Link href={href}>
<a href={href}>
<span class="text-md pl-2">
<span>{text}</span>
</span>
</Link>
</a>
</li>
</ul>
))}
Expand Down
40 changes: 0 additions & 40 deletions docs/src/components/CopyButton/CopyButton.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions docs/src/components/Icons/CheckIcon.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions docs/src/components/Icons/ChevronIcon.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions docs/src/components/Icons/CopyIcon.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions docs/src/components/Icons/ForkIcon.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions docs/src/components/Icons/StarIcon.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions docs/src/routes/angular/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Angular
---

# Angular

To setup Partytown in an Angular project take the following steps.

## Installation
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/astro/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Astro
---

# Astro

There is a first-class [Astro integration for partytown](https://github.com/withastro/astro/tree/main/packages/integrations/partytown).

## Automatic Setup
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/atomics/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Atomics
---

# Atomics

Partytown will use [Atomics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) and [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) when they're available by the browser. Some of the advantages include:

- 10x faster communication between threads compared to the service-worker requests
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/browser-support/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Browser Support
---

# Browser Support

Partytown works to ensure that all browsers can still run third-party scripts, whether they have support for service workers, atomics, or neither. This means if you're supporting legacy browsers such as IE11, the scripts should continue to work as if Partytown wasn't being used.

At its core, Partytown uses Service Workers or Atomics to do its synchronous communication from the web worker to the main thread. However, when a browser does not support either of those, it'll fallback to run the scripts the traditional way (the way it works today without Partytown).
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/common-services/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Common Services
---

# Common Services

Partytown is built with the goal that any third-party script can be ran from within it. At the lowest level, any script can add the `type="text/partytown"` attribute to have it executed from a web worker.

Below is a list of plugins / libraries that are tested & known to be working with Partytown with their commonly used [forward configs](/forwarding-events) and [proxied domains](/proxying-requests).
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Configuration
---

# Configuration

Partytown does not require a config for it to work, however a config can be set to change the defaults. At the lowest level, it's configured by setting the `window.partytown = {...}` object before the Partytown snippet script. However, higher-level integrations, such as the `<Partytown/>` component found in `@qwik.dev/partytown/react`, should provide utilities to make setting the config easier

| Config | Description |
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/copy-library-files/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Copy Library Files
---

# Copy Library Files

The [@qwik.dev/partytown](https://www.npmjs.com/package/@qwik.dev/partytown) NPM package provides the static `lib` files that need to be served from your site. Since Partytown is using a service worker, these files must be served from the same origin as your site, and cannot be hosted from a CDN. Each site is different, and how the Partytown `lib` files are hosted depends on individual setup.

The `/~partytown/` directory should serve the static files found within [@qwik.dev/partytown/lib](/distribution). The quickest way is to copy the `lib` directory into a public `/~partytown` directory within your static server. Another option would be to set up a copy task within the project's bundler, or create a build step.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/debugging/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Debugging
---

# Debugging

With `debug` mode and logging enabled, below is an example of the Partytown logs showing all calls, getters and setters:

![Partytown Debug Console Logs](https://user-images.githubusercontent.com/452425/131688576-e207cb15-7ce5-4009-a358-3e3093d51957.png)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/distribution/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Distribution
---

# Distribution

Partytown is distributed from [@qwik.dev/partytown](https://www.npmjs.com/package/@qwik.dev/partytown) using NPM. Within the distribution there are a few directories and submodules, each with their own purpose.

```bash
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/facebook-pixel/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Facebook Pixel
---

# Facebook Pixel

## Add the Pixel Script

- [Meta (Facebook) Pixel](https://www.facebook.com/business/learn/facebook-ads-pixel)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/faq/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: FAQs
---

# FAQs

## Can all scripts use Partytown?

Not necessarily. While Partytown covers many cases that allow it to work great in many cases, there are also scenarios where your script may hit an internal error and silently fail. We encourage you to thoroughly test when running any scripts first in a development environment, and then in production. Please also see the [Trade-Offs](/trade-offs) docs.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/forwarding-events/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Forwarding Events And Triggers
---

# Forwarding Events And Triggers

Many third-party scripts add a global variable to `window` which user code calls in order to send data to the service. For example, Google Tag Manager uses a [Data Layer](https://developers.google.com/tag-manager/devguide) array, and by pushing data to the array, the data is then sent on to GTM Servers. Because we're moving third-party scripts to a web worker, the main thread needs to know which variables to patch on `window`, and when these services are called, the data is correctly forwarded to the web worker. This includes queuing any events that may have happened before Partytown has even finished initializing.

For example, Google Tag Manager adds the `dataLayer` array to `window`, and Facebook Pixel adds the `fbq` function. Below is some quick pseudo code of what they're doing:
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/gatsby/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Gatsby
---

# Gatsby

The Gatsby setup is largely the same as the [React integration guide](/react), except it goes further into how to use the [Gatsby](https://gatsbyjs.com/) framework's `setHeadComponents` function, which is used to inject scripts and other common tags for websites.

For additional information, please see [How to Add Google Analytics gtag to Gatsby Using Partytown](https://www.gatsbyjs.com/blog/how-to-add-google-analytics-gtag-to-gatsby-using-partytown/).
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Getting Started
---

# Getting Started

Partytown is fairly different from most web development libraries in mainly what’s required for its setup and configuration. At the lowest level, Partytown can work with just vanilla HTML, meaning it doesn’t need to be a part of a build process, doesn’t need a bundler, doesn’t require a specific framework, etc. Because it can integrate with any HTML page, it also makes it much easier to then create wrapper components or plugins for almost any ecosystem, such as Shopify, WordPress, Nextjs, Gatsby and much more.

What's different from most web development libraries is that Partytown does _not_ get bundled with your existing site's JavaScript. Instead it purposely wants to stay separate from your code so that it can run within a web worker, and allow your code to run on the main thread. If the two were bundled we've already lost the battle.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/google-tag-manager/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Google Tag Manager
---

# Google Tag Manager

## Add the Google Tag Manager Script

- [Install Google Tag Manager for web pages](https://developers.google.com/tag-platform/tag-manager/web)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/how-does-partytown-work/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: How Does Partytown Work
---

# How Does Partytown Work

- [How Partytown's Service Worker Sync Communication Works](https://dev.to/adamdbradley/how-partytown-s-sync-communication-works-4244)

Traditionally, communicating between the main thread and worker thread _must_ be [asynchronous](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Concepts). Meaning that for the two threads to communicate, they cannot use blocking calls.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/html/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: HTML
---

# HTML

At the lowest level, Partytown is not tied to one specific framework or build tool. Because of this, Partytown can be used in any webpage as long as the HTML is updated, and the [library scripts](/copy-library-files) are hosted from the origin.

While the `partytown.js` file _could_ be an external request, it's recommended to inline the script instead. How the Partytown snippet is inlined into the page depends on each site's setup and an [integration](/integrations) may already exist for your framework.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Introduction
description: Partytown - Run third-party scripts from a web worker
---

# Run third-party scripts from a web worker

Partytown is a lazy-loaded library to help relocate resource intensive scripts into a [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API), and off of the [main thread](https://developer.mozilla.org/en-US/docs/Glossary/Main_thread). Its goal is to help speed up sites by dedicating the main thread to your code, and offloading third-party scripts to a web worker.

> Note: Partytown is still in beta and not guaranteed to work in every scenario. Please see our [FAQ](/faq) and [Trade-Off](/trade-offs) sections for more info.
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Integration Guides
---

# Integration Guides

Partytown can work with any HTML page, and doesn't require a specific framework. However, to make it easier to use in various frameworks or services, plugins/wrappers can be made for their ecosystem. Below is a current list of integrations. Please help us add more!

- [Angular](/angular)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/magento2/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Magento 2
---

# Magento 2

To integrate the partytown library functionality into your Magento 2 project, you can use the integration module for Magento2 :

<a href="https://github.com/rostilos/perspective-partytown">
Expand Down
9 changes: 2 additions & 7 deletions docs/src/routes/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@
- [Facebook Pixel](/facebook-pixel)
- [Google Tag Manager](/google-tag-manager)

## Tests|/tests
## Community

- [End-to-end Tests](/tests/)
- [Services](/tests/benchmarks/services/)
- [Benchmark](/tests/benchmarks/)
- [Local Development](https://github.com/BuilderIO/partytown/blob/main/CONTRIBUTING.md)
- [Github](https://github.com/BuilderIO/partytown)
- [Discord](https://discord.gg/aHKdpdWv7a)
- [@QwikDev](https://twitter.com/QwikDev)
- [@Builderio](https://twitter.com/builderio)
2 changes: 2 additions & 0 deletions docs/src/routes/nextjs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Next.js
---

# Next.js

The Next.js setup is largely the same as the [React integration guide](/react), except it goes further into how to add to the [NextJS](https://nextjs.org/) framework's `<Head/>` component.

## Worker Strategy
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/nuxt/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Nuxt
---

# Nuxt

There is a first-class [Nuxt integration for partytown](https://github.com/nuxt-community/partytown-module).

## Install
Expand Down
2 changes: 2 additions & 0 deletions docs/src/routes/partytown-scripts/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Partytown Scripts
---

# Partytown Scripts

## Partytown Script Type

Add the `type="text/partytown"` attribute to each individual third-party script to run from a web worker. Note that each script is opt-in, meaning that the updated `type` attribute should only be added to scripts that should run with Partytown. Partytown will _not_ automatically upgrade any scripts unless this attribute is added.
Expand Down
Loading

0 comments on commit 7786db1

Please sign in to comment.