Post by account_disabled on Feb 26, 2024 23:28:22 GMT -6
The long getSinglePostslug lang const simplePostQuery query Postslug String lang String transPostswhere slug slug lang lang slug title content post published transPostswhere lang_ne lang slug long return this.apollo Fetch query simplePostQuery variables slug long To ensure that BlogClient it is accessible everywhere we use the context for example in the function asyncData. Create the file pluginsctxinject.js import BlogClient from services export default app inject blogClient new BlogClient and add it to the section plugins in the file nuxt.config.js export default ... plugins pluginsctxinject.js.
The main view blog will be rather simple on the homepage there will be a list of articles with Iran Mobile Number List the relevant link blogpostslug. Now that the BlogClient is accessible from the context rewrite the component HomePage pagesindex.vue to take all the articles in the asyncData method and render the title and link for each article. The method asyncData receives the context as the first argument and thanks to our plugin written in the previous paragraph BlogClient it will be accessible through context.app.blogClient template section classsection div classismobile div vforpost in posts keypost.slug h post.title h nuxtlink.
More...nuxtlink div div section template script export default name HomePage async asyncData app const postsData await app.blogClient.getAllPostsHeaden return posts postsData.data.transPosts date return posts script Add the route blogpostslug by creating the component BlogPost pagesblog_slug.vue. Install the Vue Markdown component to render posts correctly as post content from Strapi comes in Markdown format yarn add vuemarkdown template section classsection div classismobile h post.title h vuemarkdown post.content vuemarkdown div section template script export default name BlogPost components vuemarkdown VueMarkdown async async Data app.
The main view blog will be rather simple on the homepage there will be a list of articles with Iran Mobile Number List the relevant link blogpostslug. Now that the BlogClient is accessible from the context rewrite the component HomePage pagesindex.vue to take all the articles in the asyncData method and render the title and link for each article. The method asyncData receives the context as the first argument and thanks to our plugin written in the previous paragraph BlogClient it will be accessible through context.app.blogClient template section classsection div classismobile div vforpost in posts keypost.slug h post.title h nuxtlink.
More...nuxtlink div div section template script export default name HomePage async asyncData app const postsData await app.blogClient.getAllPostsHeaden return posts postsData.data.transPosts date return posts script Add the route blogpostslug by creating the component BlogPost pagesblog_slug.vue. Install the Vue Markdown component to render posts correctly as post content from Strapi comes in Markdown format yarn add vuemarkdown template section classsection div classismobile h post.title h vuemarkdown post.content vuemarkdown div section template script export default name BlogPost components vuemarkdown VueMarkdown async async Data app.