Skip to content

Commit

Permalink
Merge pull request #155 from canopas/fix-tags-and-pupeeter-issue
Browse files Browse the repository at this point in the history
Fix: tags and pupeeter issue
  • Loading branch information
cp-sumi-k committed Apr 13, 2024
2 parents 3c7e778 + 42e5cd2 commit 3867956
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions admin/src/api/post/content-types/post/lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ module.exports = {
},

async afterUpdate(event) {
console.log(
"afterUpdate: ",
event.params.data.publishedAt,
event.result.is_published
);
if (event.params.data.publishedAt) {
if (!event.result.is_published) {
console.log("afterUpdate inside: ", event.result.is_published);
await strapi.db.query("api::post.post").update({
where: { id: event.result.id },
data: {
Expand Down Expand Up @@ -125,19 +119,19 @@ function generateSlug(title, slug) {
async function TagsInput(tags) {
let tagsData = [];
for (i = 0; i < tags.length; i++) {
let slug = tags[i].name
.replace(/\s/g, "-")
.replace(/[^A-Za-z-]/g, "")
.toLowerCase();

let existingTag = await strapi.db.query("api::tag.tag").findOne({
where: {
name: {
$eqi: tags[i].name,
},
},
where: { slug },
});

if (existingTag == null) {
let slug = tags[i].name
.replace(/\s/g, "-")
.replace(/[^A-Za-z-]/g, "")
.toLowerCase();
const insert = existingTag && existingTag.name != tags[i].name;
slug = insert ? slug + "-" + i : slug;

if (existingTag == null || insert) {
existingTag = await strapi.db.query("api::tag.tag").create({
data: {
slug,
Expand Down Expand Up @@ -333,7 +327,7 @@ async function runScraper(url) {
});
try {
const page = await browser.newPage();
await page.goto(url);
await page.goto(url, { waitUntil: "domcontentloaded" });
const obj = {
title: await getTitle(page),
description: await getDescription(page),
Expand Down

0 comments on commit 3867956

Please sign in to comment.