A dynamic card manager built on top of Ghost CMS.
The Xarta stack is composed by 3 services:
- Ghost: a CMS used internally by Xarta App.
- Xarta App: the Next.js app contained in this repository. Responsible for rendering the Xarta user interface and its APIs.
- A reverse proxy: an auxiliary service used as routing entrypoint to Ghost or Xarta requests. We suggest running Caddy, but you may replace it with nginx if desired.
In this guide, we suggest running all services in the host computer with the following configuration:
- Ghost: Runs on
localhost:2368
. - Xarta App: Run on port
localhost:3000
. - Caddy: Runs on port
localhost:3001
.
Optional Customizations:
- Ports can have different values as long as the configuration files mentioned in this guide are also updated to match the changes.
- If you prefer using a container-based setup (e.g. using Docker) instead, you may replace
localhost
in the configuration files with the corresponding container names. You may also create a bridge network between all three containers.
In order to run both Ghost and Xarta, let's first create a reverse proxy to route specific subpaths. We recommend using Caddy.
-
Choose one of the installation methods from Caddy's website.
-
Add a Caddyfile to inform Caddy of the desired configuration for the Xarta stack.
For example, the following configuration works for both Xarta and Ghost on localhost on ports
3000
and2368
, respectively::3001 { # Proxy /xarta subroutes to Xarta # DO NOT use /xarta/* as it will cause infinite redirects reverse_proxy /xarta* localhost:3000 { header_down Access-Control-Allow-Origin "*" header_down Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" header_down Access-Control-Allow-Headers "Content-Type, Authorization" } # Proxy anything else to Ghost reverse_proxy * localhost:2368 }
- Optional: You may further restrict
Access-Control-Allow-Origin
to your domains of choice, if desired. See Access-Control-Allow-Origin for more information.
- Optional: You may further restrict
-
Save your Caddyfile and apply it with
caddy reload
, for example:caddy reload --config /path/to/Caddyfile
-
Setup Ghost. You may choose any of the installation methods from their website.
-
Since Ghost will be accessed via reverse-proxy, we must point it to use
localhost:3001
as the default url.- If you installed Ghost on your host, using Ghost-CLI config option run
ghost config url localhost:3001
; - If you installed Ghost on a container, provide
url=http://localhost:3001
as an environment variable to it.
- If you installed Ghost on your host, using Ghost-CLI config option run
-
Access
localhost:3001
. -
Go to
/ghost
and create your admin user. Provide the following information:- Blog title
- Full name
- Password
-
Create an integration:
- Go to
/ghost/#/settings/advanced
, scroll down toIntegrations
and then clickAdd Custom Integration
. You can name itXarta
- Copy your
Content API key
andAdmin API key
tokens as well as theAPI URL
value into an.env
file in the root of this repository. Such file will be used by Xarta App to connect to Ghost:
NEXT_PUBLIC_ROOT_URL=localhost:3001 GHOST_ADMIN_API_KEY=[[Admin API key here]] GHOST_CONTENT_API_KEY=[[Content API key here]] INTERNAL_GHOST_URL=localhost:3001 NEXT_INTERNAL_ROOT_URL=localhost:3001
- Copy your into
.env
- Go to
-
Close settings
-
Optional: Go to labs > portal translate and choose a desired language in pub language (e.g.
pt-br
) -
Optional: Set a timezone
-
Optional: Configure SMTP server
- Ensure that you have already created the
.env
file in the repository, including the keys for Ghost configuration.NEXT_PUBLIC_ROOT_URL
GHOST_ADMIN_API_KEY
GHOST_CONTENT_API_KEY
INTERNAL_GHOST_URL
NEXT_INTERNAL_ROOT_URL
- Run
npm ci
to install dependencies. - Run
npm run dev
. - Access
http://localhost:3001/xarta
- Deploy a Ghost instance and configure it using the steps provided above. Save the content and api keys.
- Build
Dockerfile.next
with your public root URL, e.g.:NEXT_PUBLIC_ROOT_URL=https://xarta.dev
- Start the Next.js app with both
GHOST_ADMIN_API_KEY
andGHOST_CONTENT_API_KEY
variables provided:node .next/standalone/server.js
-
You may configure styling for classes
xarta-card
,xarta-title
,xarta-excerpt
,xarta-updated-at
,xarta-content
,xarta-footer
,xarta-custom-logo
,xarta-default-logo
to further customize your card. -
Xarta features an internal demo mode which can be used to automatically login with a username and password of choice:
- Configure both
NEXT_PUBLIC_DEMO_USERNAME
andNEXT_PUBLIC_DEMO_PASSWORD
env variables and rebuild your Next.js app.
- Configure both
Next.js APIs can be accessed at /xarta/api/
and were built to achieve functionality specific to Xarta, as well as wrap some of the Ghost APIs for convenience:
Public APIs:
code-injection
: Retrieves customhead
andfooter
customization, allowing the user to add scripts and style tags of choice.get-settings
: Returns a subset of Ghost Settings API used for Xarta UIembed-script/[id]
: Returns ascript
tag which loads the Xarta embed card and makes it responsive according to the internal content's height.get-post
: Wrapper for/posts/{id}
api from Ghost.
Next.js pages can be accessed at /xarta
create-card
: Create a new Xartaedit-card
: Edit an existing Xartaview-card
: Visualize an existing Xartaembed
: Embeds a Xartalogin
: Login routesettings
: View Xarta settings