3.8.0-beta.0 • Published 11 months ago

@pantheon-systems/pcc-vue-sdk v3.8.0-beta.0

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

Installation

npm install @pantheon-systems/pcc-vue-sdk

Setup

Initialize the Pantheon Content Cloud plugin with your PCC instance URL and site identifier.

import { pccPlugin } from "@pantheon-systems/pcc-vue-sdk";

createApp(App)
  // Install the plugin
  .use(pccPlugin, {
    siteId: import.meta.env.VITE_PCC_SITE_ID, // PCC Site Id; required
    token: import.meta.env.VITE_PCC_TOKEN, // PCC Token; required
  })
  .mount("#app");

Usage

This package exports composables and helper components to get you up and running with the Pantheon Content Cloud API.

Components

Article Renderer

The <ArticleRenderer /> component will render the article received from Content Cloud by converting the raw article data into HTML elements you can style and render in your app.

<script setup>
import { useArticle } from "@pantheon-systems/pcc-vue-sdk";
import { ArticleRenderer } from "@pantheon-systems/pcc-vue-sdk/components";

// Import the default styles
import "@pantheon-systems/pcc-vue-sdk/components/style.css";

const { id } = defineProps({
  id: {
    type: String,
    required: true,
  },
});

const { result, loading, error } = useArticle(id);
</script>

<template>
  <div v-if="loading">Loading...</div>
  <div v-if="error">{{ error }}</div>
  <div v-if="result">
    <h1>{{ result.article.title }}</h1>
    <ArticleRenderer :article="result.article" />
  </div>
</template>

Composables

All composables use the Vue Apollo library under the hood and return the same result, loading, error refs among other properties.

useArticle

Fetch an article by ID.

<script setup>
import { useArticle } from "@pantheon-systems/pcc-vue-sdk";
import { ArticleRenderer } from "@pantheon-systems/pcc-vue-sdk/components";

// Import the default styles
import "@pantheon-systems/pcc-vue-sdk/components/style.css";

const { id } = defineProps({
  id: {
    type: String,
    required: true,
  },
});

const { result, loading, error } = useArticle(id);
</script>

<template>
  <div v-if="loading">Loading...</div>
  <div v-if="error">{{ error }}</div>
  <div v-if="result">
    <h1>{{ result.article.title }}</h1>
    <ArticleRenderer :article="result.article" />
  </div>
</template>

useArticles

Fetch a list of available articles. This query does not include the article content.

<script setup>
import { useArticles } from "@pantheon-systems/pcc-vue-sdk";

const { id } = defineProps({
  id: {
    type: String,
    required: true,
  },
});

const { result, loading, error } = useArticle(id);
</script>

<template>
  <div v-if="loading">Loading...</div>
  <div v-if="error">{{ error }}</div>
  <template v-if="result">
    <div v-for="article in result.articles" :key="article.id">
      <h1>{{ article.title }}</h1>
      <p>{{ article.tags.join(", ") }}</p>
    </div>
  </template>
</template>
3.6.1-beta.0

12 months ago

3.6.2-next.0

11 months ago

3.6.1

12 months ago

3.6.0

1 year ago

3.6.2-beta.0

12 months ago

3.6.0-beta.0

1 year ago

3.6.0-beta.1

1 year ago

3.6.0-beta.2

1 year ago

3.6.0-beta.3

1 year ago

3.6.1-next.0

1 year ago

3.5.4-beta.0

1 year ago

3.5.3

1 year ago

3.7.0

11 months ago

3.5.2

1 year ago

3.7.0-next.0

12 months ago

3.5.3-beta.0

1 year ago

3.8.0-beta.0

11 months ago

3.5.1

1 year ago

3.5.0

1 year ago

3.5.2-beta.0

1 year ago

3.5.2-beta.1

1 year ago

3.4.1

1 year ago

3.4.0

1 year ago

3.3.3

1 year ago

3.3.2

1 year ago

3.3.1

1 year ago

3.3.0

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.5

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.0.18

2 years ago

2.0.17

2 years ago

2.0.15

2 years ago

2.0.14

2 years ago

2.0.13

2 years ago

2.0.12

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago