Ghost/apps/portal
Steve Larson 1f05a7890f
Added test coverage over newsletter flows (#20672)
no ref
- while reviewing the newsletter flows, it was apparent that we were
missing test coverage

Some of the tests in Portal are a bit redundant with tests added for
child components, but it didn't seem worth removing them after getting
them to work. There was a bug in our Portal fixture data that requires a
few changes, as well as some small adjustments for making tests easier
(testing-lib-react has `getByTestId` and simply a `querySelector` to use
alternate test attributes).
2024-07-27 02:20:13 +00:00
..
src Added test coverage over newsletter flows (#20672) 2024-07-27 02:20:13 +00:00
.env Moved Portal to apps/ 2023-06-16 13:37:58 +02:00
.env.development.local.example Moved Portal to apps/ 2023-06-16 13:37:58 +02:00
.eslintignore Moved Portal to apps/ 2023-06-16 13:37:58 +02:00
.yarnrc Prevented git tags from being created for apps 2023-07-10 13:09:28 +02:00
jsconfig.json Moved Portal to apps/ 2023-06-16 13:37:58 +02:00
package.json Update dependency jsdom to v24.1.1 2024-07-22 09:10:23 +02:00
README.md Updated Portal readme with updated develop and release instructions (#20576) 2024-07-10 10:05:41 +00:00
vite.config.js Hidden "info" Vite output unless in CI 2023-11-15 10:11:22 +01:00

Portal

npm version

Drop-in script to make the bulk of Ghost membership features work on any theme.

Usage

Ghost automatically injects Portal script on all sites running Ghost 4 or higher.

Alternatively, Portal can be enabled on non-ghost pages directly by inserting the below script on the page.

<script defer src="https://unpkg.com/@tryghost/portal@latest/umd/portal.min.js" data-ghost="https://mymemberssite.com"></script>

The data-ghost attribute expects the URL for your Ghost site, which is the only input Portal needs to work with your site's membership data via Ghost APIs.

Custom trigger button

By default, the script adds a default floating trigger button on the bottom right of your page which is used to trigger the popup on screen.

Its possible to add custom trigger button of your own by adding data attribute data-portal to any HTML tag on page, and also specify a specific page to open from it by using it as data-portal=signup.

The script also adds custom class names to this element for open and close state of popup - gh-portal-open and gh-portal-close, allowing devs to update its UI based on popup state.

Refer the docs to read about ways in which Portal can be customized for your site.

Develop

Run Portal within the Ghost monorepo with:

yarn dev --portal

Alternatively, use yarn dev --all to load Portal and other supported apps/services, see dev.js for more information.


To run Portal in a standalone fashion, use yarn start and open http://localhost:3000.

Build

To create a production minified bundle in umd/portal.min.js:

yarn build

Test

To run tests in watch mode:

yarn test

Release

A patch release can be rolled out instantly in production, whereas a minor/major release requires the Ghost monorepo to be updated and released. In either case, you need sufficient permissions to release @tryghost packages on NPM.

Patch release

  1. Run yarn ship and select a patch version when prompted
  2. (Optional) Clear JsDelivr cache to get the new version out instantly (docs). Typically, you'll need to open https://purge.jsdelivr.net/ghost/portal@~${PORTAL_VERSION}/umd/portal.min.js and https://purge.jsdelivr.net/ghost/portal@~${PORTAL_VERSION}/umd/main.css in your browser, where PORTAL_VERSION is the latest minor version in ghost/core/core/shared/config/defaults.json (code)

Minor / major release

  1. Run yarn ship and select a minor or major version when prompted
  2. Update the Portal version in ghost/core/core/shared/config/defaults.json to the new minor or major version (code)
  3. Wait until a new version of Ghost is released

Copyright & License

Copyright (c) 2013-2024 Ghost Foundation - Released under the MIT license.