3.4.0 • Published 3 days ago

@pantheon-systems/pcc-vue-sdk v3.4.0

Weekly downloads
-
License
-
Repository
-
Last release
3 days 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.4.0

3 days ago

3.3.3

14 days ago

3.3.2

19 days ago

3.3.1

25 days ago

3.3.0

30 days ago

3.2.1

1 month ago

3.2.0

1 month ago

3.1.2

2 months ago

3.1.1

2 months ago

3.1.0

2 months ago

3.0.5

3 months ago

3.0.4

3 months ago

3.0.3

3 months ago

3.0.1

4 months ago

3.0.0

4 months ago

2.0.18

5 months ago

2.0.17

5 months ago

2.0.15

5 months ago

2.0.14

6 months ago

2.0.13

6 months ago

2.0.12

6 months ago

2.0.11

6 months ago

2.0.10

6 months ago

2.0.9

6 months ago

2.0.8

6 months ago

2.0.7

6 months ago

2.0.6

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.3

7 months ago

2.0.2

7 months ago

2.0.1

8 months ago

2.0.0

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago