Adding Simple Copies to Strapi
- Goto https://cms.powr-staging.io/admin and login
- Click "Simple Copies" button located on left menu
- In the opened main block click on blue button "+ Add New Simple Copies"
- In the "Name" input field; type the name of your Simple Copy (e.g general.main.block), same with "Body". "Body" its the value of the "name" which will be displayed.
- Select localization from select dropdown (default English)
- Click green "Save" button, now your Simple Copy is saved, but not yet published. You may want to add localizations to your "Name". (You can select other localizations on the same page after saving).
- After you are done, you can press Publish. Now your Copies are available!
Searching
- On Simple Copy section (Click "Simple Copies" button located on left menu) you can find a Copies by their "Name" typing "Name" on top input bar placeholded with "Search for an entry..."
Deleting an existing Copy
- Open existing Copy, click on red button "Delete this entry".
See this gif to see how it works https://powrteam.slack.com/files/URV6B7DDF/F0351FB5NMB/simple-copies.gif?origin_team=T06L46R5X&origin_channel=D02H2421J3W
API
- Strapi url
- To get strapi access token
- Open documentat tab.
- The access token is in the middle of the documentation page.
- API documentation
- Examples of requests with AXIOS
const axios = require('axios');
const qs = require('qs');
const token =
'your access token';
const strapi_url = 'https://cms.powr-staging.io';
const query = qs.stringify({
_limit: 3000,
});
const strapi_client = axios.create({ // strapi client for POST and PUT requests
baseURL: `${strapi_url}`,
headers: { Authorization: 'Bearer ' + token },
});
const get_platforms = async () =>
await axios.get(`${strapi_url}/platforms?${query}`); // GET requests doesn't require token
const get_app_slugs = async () =>
await axios.get(`${strapi_url}/app-slug-simple-copies?${query}`);
const get_general_copies = async () =>
await axios.get(`${strapi_url}/general-copies?${query}`);
module.exports = { strapi_client, get_app_slugs, get_platforms, get_general_copies, query };
Adding Copies in batch
const axios = require('axios');
const token = ''; // GET THIS TOKEN HERE: https://cms.powr-staging.io/admin/plugins/documentation
const strapi_url = 'https://cms.powr-staging.io';
const strapi_client = axios.create({
baseURL: strapi_url,
headers: { Authorization: `Bearer ${token}` },
});
// All your copies that need to be added
const DATA = {
'countdowntimer.content.active_dates': 'Countdown Active Dates',
};
async function main() {
try {
for (const key of Object.keys(DATA)) {
// Running one by one because strapi doesn't support bulk adding
const res = await strapi_client.post('/simple-copies', {
name: key,
body: DATA[key],
locale: 'en',
});
console.log(res.data);
}
} catch (error) {
console.log(error);
}
}
main();