[Unit]Description=Set up specific macvlan route for a Docker containerAfter=network.target[Service]Type=oneshotRemainAfterExit=yes# Replace <your-network-interface> with the actual interface nameExecStart=/usr/bin/ip link add mvlan0 link <your-network-interface> type macvlan mode bridgeExecStart=/usr/bin/ip addr add <unused-ip>/24 dev mvlan0ExecStart=/usr/bin/ip link set mvlan0 upExecStart=/usr/bin/ip route del 192.168.100.0/24 dev mvlan0ExecStart=/usr/bin/ip route add 192.168.100.22 dev mvlan0ExecStop=/usr/bin/ip link delete mvlan0[Install]WantedBy=multi-user.target
GET https://blogkit.apps.gianthard.rocks/api/v1/slugify?t=如何科学饲养母猪HTTP/2 200 OKserver:nginxdate:Mon, 19 Aug 2024 10:01:06 GMTcontent-type:application/json; charset=utf-8age:189318cache-control:public,max-age=31536000content-length:24x-http2-stream-id:3"scientific-sow-rearing"
要在 WordPress 中自动调用的话,需要在 WordPress 管理页面添加一些代码:
functionsuggest_slug_from_api($slug,$post_id,$post_status,$post_type,$post_parent,$original_slug ){// Only apply for new posts or when the slug is emptyif(empty($slug)){$post =get_post($post_id);$title =$post ?$post->post_title :'';if(empty($title)){return$slug;// Return original slug if no title}$api_url ='https://blogkit.apps.gianthard.rocks/api/v1/slugify';// Encode the title for use in URL$query =http_build_query(array('t'=>$title));$url =$api_url .'?'.$query;// Make the API request$response =wp_remote_get($url);// Check if the request was successfulif(!is_wp_error($response)&&wp_remote_retrieve_response_code($response)==200){$body =wp_remote_retrieve_body($response);$suggested_slug =json_decode($body,true);// If we got a valid slug, use itif($suggested_slug &&is_string($suggested_slug)){return$suggested_slug;}}}// If anything goes wrong or if the post already has a custom slug, return the original slugreturn$slug;}add_filter('wp_unique_post_slug','suggest_slug_from_api',10,6);