Extract url frop main url
This commit is contained in:
parent
c0f4b3c979
commit
3aa892cd1d
1 changed files with 17 additions and 15 deletions
14
gatsbyfeed
14
gatsbyfeed
|
|
@ -3,25 +3,27 @@
|
||||||
#Usage : Extract jsonfeed from gatsbyjs agenda
|
#Usage : Extract jsonfeed from gatsbyjs agenda
|
||||||
|
|
||||||
function to_feed(){
|
function to_feed(){
|
||||||
curl -s $link | jq '{"version":"https://jsonfeed.org/version/1.1", "title":"RDS", "home_page_url": "https://example.org/", "feed_url": "https://example.org/feed.json","items": [.result.data.allNodeActualites.edges[] | {title: .node.title, url: .node.path.alias, content_html:.node.body.processed}]}'
|
# Extraire le domaine de l'URL (home_page_url)
|
||||||
|
home_page_url=$(echo "$link" | sed -E 's|^https?://([^/]+).*|\1|' | xargs -I {} echo "https://{}")
|
||||||
|
|
||||||
|
# Utiliser le nom de domaine comme titre par défaut (ou personnaliser si besoin)
|
||||||
|
title=$(echo "$home_page_url" | sed -E 's|https://||' | sed -E 's/\..*//' | tr '[:lower:]' '[:upper:]')
|
||||||
|
|
||||||
|
curl -s "$link" | jq --arg home_page_url "$home_page_url" --arg title "$title" \
|
||||||
|
'{"version":"https://jsonfeed.org/version/1.1", "title": $title, "home_page_url": $home_page_url, "feed_url": $home_page_url + "/feed.json", "items": [.result.data.allNodeActualites.edges[] | {title: .node.title, url: .node.path.alias, content_html:.node.body.processed}]}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# https://learntutorials.net/fr/bash/topic/746/script-avec-des-parametres
|
|
||||||
# Load the user defined parameters
|
|
||||||
while [[ $# -gt 0 ]]
|
while [[ $# -gt 0 ]]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
||||||
https://*.json|http://*.json)
|
https://*.json|http://*.json)
|
||||||
link="$1"
|
link="$1"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--help|*)
|
--help|*)
|
||||||
echo "gatsbyfeed : URL manquante"
|
echo "gatsbyfeed : URL manquante"
|
||||||
echo "Usage : gatsbyfeed URL"
|
echo "Usage : gatsbyfeed URL"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue