{"id":3809,"date":"2023-10-31T16:15:03","date_gmt":"2023-10-31T07:15:03","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=3809"},"modified":"2023-10-31T16:17:12","modified_gmt":"2023-10-31T07:17:12","slug":"wordpress%e3%81%a7%e5%85%a8%e8%a8%98%e4%ba%8b%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%97%e3%81%a6next-js%e3%81%ab%e7%a7%bb%e8%a1%8c%e3%81%99%e3%82%8b%e6%89%8b%e9%a0%86","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=3809","title":{"rendered":"WordPress\u3067\u5168\u8a18\u4e8b\u3092\u51fa\u529b\u3057\u3066Next.js\u306b\u79fb\u884c\u3059\u308b\u624b\u9806"},"content":{"rendered":"<p>WordPress\u304b\u3089Next.js\u306b\u79fb\u884c\u3059\u308b\u3053\u3068\u306f\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u3084\u67d4\u8edf\u6027\u306e\u5411\u4e0a\u3092\u76ee\u6307\u3059\u4e0a\u3067\u9b45\u529b\u7684\u306a\u9078\u629e\u3067\u3059\u3002\u3053\u306e\u30d7\u30ed\u30bb\u30b9\u306f\u52b4\u529b\u304c\u304b\u304b\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u8a18\u4e8b\u3067\u306fWordPress\u3067\u306e\u5168\u8a18\u4e8b\u306e\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u304b\u3089Next.js\u3067\u306e\u6d3b\u7528\u307e\u3067\u306e\u624b\u9806\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u6bd4\u8f03\u7684\u30b7\u30f3\u30d7\u30eb\u306b\u79fb\u884c\u4f5c\u696d\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#WordPress\"><span class=\"toc_number toc_depth_1\">1<\/span> WordPress\u304b\u3089\u5168\u3066\u306e\u8a18\u4e8b\u3092\u51fa\u529b\u3059\u308b<\/a><\/li><li><a href=\"#nodejsxml\"><span class=\"toc_number toc_depth_1\">2<\/span> node.js\u3067xml\u3092\u30d1\u30fc\u30b9\u3059\u308b<\/a><\/li><li><a href=\"#mdx\"><span class=\"toc_number toc_depth_1\">3<\/span> \u8a18\u4e8b\u30c7\u30fc\u30bf\u3092mdx\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308b<\/a><\/li><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">4<\/span> \u7d50\u8ad6<\/a><\/li><\/ul><\/div>\n<h2><span id=\"WordPress\">WordPress\u304b\u3089\u5168\u3066\u306e\u8a18\u4e8b\u3092\u51fa\u529b\u3059\u308b<\/span><\/h2>\n<p>\u6700\u521d\u306b\u3001WordPress\u306e\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u304b\u3089\u5168\u3066\u306e\u8a18\u4e8b\u3092\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306fXML\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u624b\u9806\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\uff1a<\/p>\n<p>1. WordPress\u306e\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<br \/>\n2. \u5de6\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u300c\u30c4\u30fc\u30eb\u300d\u3092\u9078\u629e\u3057\u3001\u300c\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n3. \u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u306e\u5bfe\u8c61\u3092\u300c\u6295\u7a3f\u300d\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n4. \u300c\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066XML\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<h2><span id=\"nodejsxml\">node.js\u3067xml\u3092\u30d1\u30fc\u30b9\u3059\u308b<\/span><\/h2>\n<p>\u6b21\u306b\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305fXML\u30d5\u30a1\u30a4\u30eb\u3092\u30d1\u30fc\u30b9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u4f8b\u3067\u306fNode.js\u3092\u4f7f\u7528\u3057\u307e\u3059\u304c\u3001\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3082\u540c\u69d8\u306e\u51e6\u7406\u304c\u53ef\u80fd\u3067\u3059\u3002\u4ee5\u4e0b\u306eNode.js\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u53c2\u8003\u306b\u3057\u3066XML\u30d5\u30a1\u30a4\u30eb\u3092\u30d1\u30fc\u30b9\u3057\u307e\u3059\uff1a<\/p>\n<p><code>const fs = require('fs');<br \/>\nconst xml2js = require('xml2js');<\/code><\/p>\n<p><code>\/\/ XML\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080<br \/>\nconst xmlString = fs.readFileSync('your-xml-file.xml', 'utf-8');<\/code><\/p>\n<p><code>\/\/ xml2js\u3092\u4f7f\u7528\u3057\u3066XML\u3092\u30d1\u30fc\u30b9<br \/>\nxml2js.parseString(xmlString, (err, result) =&gt; {<br \/>\nif (err) {<br \/>\nconsole.error(err);<br \/>\nreturn;<br \/>\n}<\/p>\n<p>\/\/ \u30d1\u30fc\u30b9\u3055\u308c\u305fXML\u30c7\u30fc\u30bf\u306b\u30a2\u30af\u30bb\u30b9<br \/>\nconst items = result.rss.channel[0].item;<\/p>\n<p>items.forEach(item =&gt; {<br \/>\nconst title = item.title[0];<br \/>\nconst link = item.link[0];<br \/>\nconst pubDate = item.pubDate[0];<br \/>\nconst creator = item['dc:creator'][0];<\/p>\n<p>\/\/ content:encoded\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3057\u30ed\u30b0\u306b\u51fa\u529b<br \/>\nif (item['content:encoded']) {<br \/>\nconst contentEncoded = item['content:encoded'][0];<br \/>\nconsole.log(`Title: ${title}`);<br \/>\nconsole.log(`Link: ${link}`);<br \/>\nconsole.log(`PubDate: ${pubDate}`);<br \/>\nconsole.log(`Creator: ${creator}`);<br \/>\nconsole.log(`Content: ${contentEncoded}`);<br \/>\n}<br \/>\n});<br \/>\n});<\/p>\n<p><\/code><code><\/code><code><\/code><\/p>\n<p>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001XML\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u3001\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2><span id=\"mdx\">\u8a18\u4e8b\u30c7\u30fc\u30bf\u3092mdx\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308b<\/span><\/h2>\n<p>\u6700\u7d42\u7684\u306a\u30b9\u30c6\u30c3\u30d7\u306f\u3001\u30d1\u30fc\u30b9\u3057\u3066\u53d6\u5f97\u3057\u305f\u8a18\u4e8b\u30c7\u30fc\u30bf\u3092Next.js\u3067\u5229\u7528\u3067\u304d\u308b\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001WordPress\u304b\u3089\u53d6\u5f97\u3057\u305f\u8a18\u4e8b\u30c7\u30fc\u30bf\u3092Next.js\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u7d71\u5408\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2><span id=\"i\">\u7d50\u8ad6<\/span><\/h2>\n<p>WordPress\u304b\u3089Next.js\u306b\u79fb\u884c\u3059\u308b\u3053\u3068\u306f\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u67d4\u8edf\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u624b\u6bb5\u3068\u3057\u3066\u9b45\u529b\u7684\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001WordPress\u304b\u3089\u5168\u8a18\u4e8b\u3092\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3057\u3001XML\u30d5\u30a1\u30a4\u30eb\u3092\u30d1\u30fc\u30b9\u3057\u3066\u8a18\u4e8b\u30c7\u30fc\u30bf\u3092Next.js\u3067\u6d3b\u7528\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u306b\u5f93\u3046\u3053\u3068\u3067\u3001\u30b9\u30e0\u30fc\u30ba\u306a\u79fb\u884c\u4f5c\u696d\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002\u65b0\u3057\u3044\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u69cb\u7bc9\u3084\u65e2\u5b58\u306e\u30b5\u30a4\u30c8\u306e\u6539\u5584\u3092\u76ee\u6307\u3059\u969b\u306b\u3001\u3053\u308c\u3089\u306e\u624b\u9806\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u304b\u3089Next.js\u306b\u79fb\u884c\u3059\u308b\u3053\u3068\u306f\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u3084\u67d4\u8edf\u6027\u306e\u5411\u4e0a\u3092\u76ee\u6307\u3059\u4e0a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-Zr","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/3809"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3809"}],"version-history":[{"count":5,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/3809\/revisions"}],"predecessor-version":[{"id":3816,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/3809\/revisions\/3816"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}