Skip to content

Commit

Permalink
Improve error handling when fetching blog feeds (#798)
Browse files Browse the repository at this point in the history
* ignore blogs/feeds json

* improve error handling of fetching external feeds

* add optional chaining to json parsing
  • Loading branch information
sserrata authored Dec 13, 2024
1 parent cbd2014 commit 3256251
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ products/**/*.tag.mdx
products/**/sidebar.js
products/**/sidebar.ts
products/**/versions.json

# downloaded feeds/blogs
src/**/blogs.json
src/**/feeds.json
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"license": "",
"scripts": {
"docusaurus": "docusaurus",
"start": "yarn gen-all && docusaurus start",
"start": "yarn getAllFeeds && yarn gen-all && docusaurus start",
"build": "run-script-os",
"build:windows": "set NODE_OPTIONS=--max_old_space_size=8192 && yarn gen-all && yarn docusaurus build",
"build:default": "export NODE_OPTIONS=--max_old_space_size=8192 && yarn gen-all && yarn docusaurus build",
"build-github": "export NODE_OPTIONS=--max_old_space_size=96000 && yarn getBlogs && yarn getHashicorpBlogs && yarn gen-all && DOCUSAURUS_PERF_LOGGER=true yarn docusaurus build",
"build-github": "export NODE_OPTIONS=--max_old_space_size=96000 && yarn getAllFeeds && yarn gen-all && DOCUSAURUS_PERF_LOGGER=true yarn docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand All @@ -21,11 +21,12 @@
"gen-all": "docusaurus gen-api-docs all --all-versions",
"clean-all": "docusaurus clean-api-docs all --all-versions",
"re-gen": "yarn clean-all && yarn gen-all",
"getBlogs": "curl -H \"Accept: application/json\" \"https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fmedium.com%2Ffeed%2Fpalo-alto-networks-developer-blog\" -o src/components/Medium/blogs.json",
"getHashicorpBlogs": "curl -H \"Accept: application/json\" \"https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fwww.hashicorp.com%2Fblog%2Fproducts%2Fterraform%2Ffeed.xml\" -o src/components/ProductLandingPage/Feeds/feeds.json",
"start:netsec": "cross-env PRODUCTS_INCLUDE=cdss,threat-vault,dns-security,iot,expedition,cloudngfw,cdl,panos,terraform,ansible,splunk,aiops-ngfw-bpa,email-dlp,dlp yarn start",
"getBlogs": "curl -f -s -H \"Accept: application/json\" \"https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fmedium.com%2Ffeed%2Fpalo-alto-networks-developer-blog\" -o src/components/Medium/blogs.json || (echo \"[]\" > src/components/Medium/blogs.json)",
"getHashicorpBlogs": "curl -f -s -H \"Accept: application/json\" \"https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fwww.hashicorp.com%2Fblog%2Fproducts%2Fterraform%2Ffeed.xml\" -o src/components/ProductLandingPage/Feeds/feeds.json || (echo \"[]\" > src/components/ProductLandingPage/Feeds/feeds.json)",
"getAllFeeds": "yarn --silent getBlogs && yarn --silent getHashicorpBlogs",
"start:netsec": "cross-env PRODUCTS_INCLUDE=cdss,threat-vault,dns-security,iot,expedition,cloudngfw,cdl,panos,terraform,ansible,splunk,aiops-ngfw-bpa,email-dlp,dlp,ai-runtime-security yarn start",
"start:splunk": "cross-env PRODUCTS_INCLUDE=panos,terraform,ansible,splunk yarn start",
"start:sase": "cross-env PRODUCTS_INCLUDE=sase,access,sdwan yarn start",
"start:sase": "cross-env PRODUCTS_INCLUDE=sase,access,sdwan,scm yarn start",
"start:cloud": "cross-env PRODUCTS_INCLUDE=prisma-cloud,compute yarn start",
"clean": "yarn clean-all && yarn clear && yarn cache clean && yarn rimraf ./**/node_modules",
"sos": "yarn clean && yarn install",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Medium/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./Slider.scss";
import styles from "./styles.module.css";

const blog_json = require("./blogs.json");
const blogs = blog_json.items.slice(0, 9);
const blogs = blog_json?.items?.slice(0, 9);

function Medium() {
const sliderSettings = {
Expand Down

0 comments on commit 3256251

Please sign in to comment.