投稿時間:2023-01-13 10:15:17 RSSフィード2023-01-13 10:00 分まとめ(18件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
ROBOT ロボスタ 『ONE PIECE』の世界の日常を「窓」を通して体験 「Atmoph Window 2」が『ONE PIECE ODYSSEY』とコラボ https://robotstart.info/2023/01/13/atmoph-window-one-piece.html 2023-01-13 00:00:44
IT ITmedia 総合記事一覧 [ITmedia エグゼクティブ] 「現場主義で成長加速」 オムロン次期社長の辻永順太氏 https://mag.executive.itmedia.co.jp/executive/articles/2301/13/news081.html itmedia 2023-01-13 09:24:00
IT SNSマーケティングの情報ならソーシャルメディアラボ【Gaiax】 【12月の主要SNSニュースまとめ】Twitter法人向けのサブスク発表・Instagram「Notes」などの新機能を発表!ほか https://gaiax-socialmedialab.jp/post-133820/ faceb 2023-01-13 00:49:34
TECH Techable(テッカブル) 大阪「千日前道具屋筋商店街」をバーチャル空間で楽しむ!楽しさ倍増の観光方法が実現! https://techable.jp/archives/190105 道具屋筋 2023-01-13 00:45:42
TECH Techable(テッカブル) アスリートのコンディションを管理する「ONE TAP SPORTS」、スマホアプリが登場 https://techable.jp/archives/189949 onetapsports 2023-01-13 00:45:38
TECH Techable(テッカブル) 横浜市消防局監修VRを活用した次世代型マンション消防訓練サービス。大和ハウスグループが提供 https://techable.jp/archives/190042 大和ハウスグループ 2023-01-13 00:45:34
デザイン コリス すべてのページに美しい配色がいっぱい! デザインで文字を扱うときにぴったりな配色本 -色数は少ないほうがかっこいい! https://coliss.com/articles/book-review/isbn-9784802613927.html 続きを読む 2023-01-13 00:36:34
python Pythonタグが付けられた新着投稿 - Qiita OpenCVを使わず幾何変換する https://qiita.com/RDProm/items/d9d7e618b013ccda2079 opencv 2023-01-13 09:36:03
AWS AWSタグが付けられた新着投稿 - Qiita [AWS学習] 責任分担セキュリティモデルとIAMについての学習メモ https://qiita.com/SNobu/items/3ce2638e770e7ea085f4 不正アクセス 2023-01-13 09:32:32
Azure Azureタグが付けられた新着投稿 - Qiita DP-900: Microsoft Azure のデータの基礎に合格した話 https://qiita.com/Rei1729/items/2e6e1ce74dbab97c627b adventcalendar 2023-01-13 09:53:46
技術ブログ Developers.IO BacklogのAPIを使って課題添付ファイルをまるごとダウンロードしてみた https://dev.classmethod.jp/articles/backilogapi_get_issue_attached_files/ backlog 2023-01-13 00:52:41
技術ブログ Developers.IO Jestのドキュメント翻訳コントリビュートしてみた https://dev.classmethod.jp/articles/eetann-contribute-jest-translate/ delivery 2023-01-13 00:38:53
海外TECH DEV Community How to Create an Astro Search component 🔍🤔 https://dev.to/danidiaztech/how-to-create-an-astro-search-component-2731 How to Create an Astro Search component Implementing search functionality on a full stack application is hard But doing it on a static site might seem impossible After all you don t havea database to query right Fortunately the Astro web framework has an API where you can fetch the markdown or MDX files you need After fetching all the data we ll able to searchfor a specific query provided by our users Here is a demo of what we re going to build Let s build an Astro search component by using React and fuse js Note The source code for this project is available on this GitHub repository Creating an Astro Blog ProjectLet s kick things off by creating an Astro project I built an in depth guide on how to start an Astro projectif you have any questions about this process I ll be using the recommended starting template by Astro npm create astro latestWhere would you like to create your new project …Astro search componentHow would you like to setup your new project ›a few best practices recommended I added the MDX Astro integration to be able to use both md and mdx file extensions but if you only use plain markdown files this is not necessary Run the followingat the root of your project npx astro add mdxIf you said yes to every option the CLI tool modified automatically modified yourAstro config file Modify the src pages index astro file to look like the following This page should be available under localhost import Layout from layouts Layout astro const allPosts await Astro glob posts md mdx const posts allPosts filter post gt post frontmatter draft amp amp post frontmatter slug lt Layout title MyBlog gt lt h gt Welcome to my Blog lt h gt lt Layout gt The Layout component is provided by the starter template of Astro If you don t have it create one under the src layouts Layout astro filename or just wrap the content insidea normal HTML structure For now don t worry about the styles We ll be applying Tailwind CSSlater in the tutorial After this create an Astro page to display blog posts dynamically Create a file named src pages slug astro The squared brackets mean that to display the page we must pass a parameter called slug to the URL In this case the page URL of any posts would be localhost slug import Layout from layouts Layout astro export async function getStaticPaths const allPosts await Astro glob posts md mdx const posts allPosts filter post gt post frontmatter draft amp amp post frontmatter slug return posts map post gt params slug post frontmatter slug props post const post Astro props lt Layout title post frontmatter title gt lt h gt post frontmatter title lt h gt lt p gt post frontmatter description lt p gt lt post Content gt lt Layout gt Note how we use the getStaticPaths function to dynamically create the paths of our posts The parameter is a slug field that we must manually specify You can automate it by applying a slugifyfunction to the posts filenames but this is outside the scope of the tutorial Now let s create some posts with different titles and descriptions inside the src posts directory you have to create this folder The source code of the project up to this point including the dummy posts are available on this GitHub branch Create the Astro Search ComponentFirst we re going to create an Astro file src components SearchBar astro that fetches all the posts and sends them as a prop to the React search component which we ll later create in the same components folder It s like creating a client that uses an API and then creating the API itself import Search from Search const allPosts await Astro glob posts md mdx const posts allPosts filter post gt post frontmatter draft amp amp post frontmatter slug lt Search client load searchList posts gt We filter the posts so they are not drafts and they have a defined slug Then we pass this post list tothe React component we re going to create next As you can see it s a pretty simple client which means all the logic relies on the React component Building a React Search componentBefore doing any code let s add the dependencies to our project First add the React integration from astrojs react and the fuzzy search library fuse js which we ll use to search through the markdown files You can read more about fuzzy search or more formally approximate stringmatching in this article On the root of the project run npx astro add reactnpm i save fuse jsNow create a jsx file named Search jsx inside the components folder which will contain a React function component At the top of this file import Fuse the fuse js API and the useState hook which allows usto track the state an object that contains data about a component of our search input import Fuse from fuse js import useState from react Set the options for the Fuse object with a dictionary Configs fuse js const options keys frontmatter title frontmatter description frontmatter slug includeMatches true minMatchCharLength threshold Now let s create our Search function component It ll take a search list as a prop function Search searchList Following code export default Search Inside this function use the useState hook with anempty initial value to trackthe state of a variable query the input of the user const query setQuery useState Create a Fuse object with the initial search list and theoptions we defined above const fuse new Fuse searchList options Now define the posts we re going to display in the search bar by using thesearch method of the Fuse object Set a limit to the posts const posts fuse search query map result gt result item slice This search method returns a list of the results according to the query Each result has an item object containing the data of the item found and refIndex Because weonly want to get the data from the item we transform the result object to get only the item The slice function returns only the first results ーthe most precise results You can change it according to your needs Now create a handler function handleOnSearch to change the value of the query according to theinput from the user function handleOnSearch target const value target setQuery value We ll pass this function to the input HTML tag You can learn more about handling forms in the official React Docs Finally return a label and an input text field withthe query as value and handleOnSearch as the handler of the onChange event return lt gt lt label gt Search lt label gt lt input type text value query onChange handleOnSearch placeholder Search posts gt query length gt amp amp lt p gt Found posts length posts length result results for query lt p gt lt ul gt posts amp amp posts map post gt lt li gt lt a href post frontmatter slug gt post frontmatter title lt a gt post frontmatter description lt li gt lt ul gt lt gt The src components Search jsx file should look like this import Fuse from fuse js import useState from react Configs fuse js const options keys frontmatter title frontmatter description frontmatter slug includeMatches true minMatchCharLength threshold function Search searchList User s input const query setQuery useState const fuse new Fuse searchList options Set a limit to the posts const posts fuse search query map result gt result item slice function handleOnSearch target const value target setQuery value return lt gt lt label gt Search lt label gt lt input type text value query onChange handleOnSearch placeholder Search posts gt query length gt amp amp lt p gt Found posts length posts length result results for query lt p gt lt ul gt posts amp amp posts map post gt lt li gt lt a href post frontmatter slug gt post frontmatter title lt a gt post frontmatter description lt li gt lt ul gt lt gt export default Search Congrats now you have a fully functional search bar on your site DemoHere is a demo of the component we have up to this point The above component gets global styles from my site thus the dark mode still applies If you want to see what the whole project looks like now check out this GitHub branch Apply Tailwind CSS stylesLet s finish this project by adding some Tailwind my favorite CSS framework styles to the search bar component To do this install the Astro Tailwind integration and the typography plugin to modify the styles in markdown rendered pages like the posts npx astro add tailwindnpm i save tailwindcss typographyTo the generated tailwind config cjs file in the root of your project add the following inside the plugins list tailwind config cjs type import tailwindcss Config module exports content src astro html js jsx md mdx svelte ts tsx vue theme extend plugins require tailwindcss typography Here is the src pages index astro file lt Layout title MyBlog gt lt div class py lg py gt lt h class text xl lg text xl uppercase font bold bg clip text text transparent bg gradient to tr from blue to green text center gt Welcome to my Blog lt h gt lt div gt lt div class max w xl mx auto gt lt SearchBar gt lt div gt lt Layout gt Now to stylize the search bar we must add a className attribute to the tagsinside the return statement I ll also use a search icon from Iconify one of the largest collections of open source icons src components Search jsx gt Searchreturn lt div gt lt label htmlFor search className mb text sm font medium text gray sr only dark text white gt Search lt label gt lt div className relative gt lt div className absolute inset y left flex items center pl pointer events none gt lt svg xmlns className icon icon tabler icon tabler search width height viewBox strokeWidth stroke currentColor fill none strokeLinecap round strokeLinejoin round gt lt path stroke none d M hvHz fill none gt lt path gt lt circle cx cy r gt lt circle gt lt line x y x y gt lt line gt lt svg gt lt div gt lt input type text id search value query onChange handleOnSearch className block w full p pl text sm text gray border border gray rounded lg bg gray focus outline none focus ring blue focus border blue placeholder Search for anything gt lt div gt query length gt amp amp lt div className my gt Found posts length posts length result results for query lt div gt lt ul className list none gt posts amp amp posts map post gt lt li className py gt lt a className text lg text blue hover text blue hover underline underline offset href post frontmatter slug gt post frontmatter title lt a gt lt p className text sm text gray gt post frontmatter description lt p gt lt li gt lt ul gt lt div gt This is how the index page should look like Finally modify the src pages slug astro file to make the articles look prettier lt Layout title post frontmatter title gt lt div class pb mx auto max w xl prose prose md prose headings font bold prose a text blue gt lt h class text center text xl pt pb gt post frontmatter title lt h gt lt p class text center text lg text gray pb gt post frontmatter description lt p gt lt post Content gt lt div gt lt Layout gt The prose class allows us to add Tailwind styles to HTML content we don t control ーlike HTML rendered from markdown files Now when you visit an article you ll have the following page SummaryIn this tutorial you learned how to create an Astro Searchcomponent with React and fuse js You used the Astro API to fetch all the published posts passed themas a search list to a function React component and created a fuse jsobject to search posts the users type in the input field Finally you installed the Tailwind integration which allowed you to stylize your site without writing custom CSS If you have any feedback on this tutorial please let me know 2023-01-13 00:33:06
ニュース BBC News - Home Consider statins for millions more people in England, NHS told https://www.bbc.co.uk/news/health-64251636?at_medium=RSS&at_campaign=KARANGA guidelines 2023-01-13 00:12:39
ニュース BBC News - Home Smart appliances could stop working after two years, says Which? https://www.bbc.co.uk/news/technology-64249388?at_medium=RSS&at_campaign=KARANGA device 2023-01-13 00:52:00
ニュース BBC News - Home The Papers: 'Life-saving statin handout' and 'Grenfell agony' https://www.bbc.co.uk/news/blogs-the-papers-64257766?at_medium=RSS&at_campaign=KARANGA grenfell 2023-01-13 00:09:15
IT 週刊アスキー アップル15インチ「MacBook Air」2023年発表はやっぱりあるか https://weekly.ascii.jp/elem/000/004/120/4120313/ bloomberg 2023-01-13 09:30:00
マーケティング AdverTimes プレゼンに驚きや感動はいらない https://www.advertimes.com/20230113/article408737/ 驚き 2023-01-13 01:00:15

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)