HackerNewsFullstack/templates/static/ItemView.b93ae7d5.js
2022-04-01 17:03:49 +02:00

2 lines
1.4 KiB
JavaScript

import{_ as l,r as d,o as i,c as r,a as u,w as m,t as o,b as a,d as t,e as p,f as h,p as c,g as _}from"./index.1f1b2f0d.js";const g=s=>(c("data-v-2750d908"),s=s(),_(),s),f=g(()=>t("button",null,"back",-1)),v={key:0,class:"loading"},y={key:1,class:"error"},k={key:2,class:"content"},I=p(" Link: "),b=["href"],S=["innerHTML"],w={data(){return{loading:!1,error:null,item:null}},created(){this.$watch(()=>this.$route.params,()=>{this.getItem()},{immediate:!0})},methods:{getItem(){this.error=this.item=null,this.loading=!0,h.get(`http://localhost:5000/item/${Number(this.$route.params.id)}`).then(s=>{this.loading=!1,this.item=JSON.parse(s.data.item)}).catch(s=>{this.loading=!1,this.error=s.toString()})}}},L=Object.assign(w,{props:{id:{type:String,required:!0}},setup(s){return(e,N)=>{const n=d("RouterLink");return i(),r("div",null,[u(n,{to:"/"},{default:m(()=>[f]),_:1}),e.loading?(i(),r("div",v," Loading Item "+o(this.$route.params.id)+"... ",1)):a("",!0),e.error?(i(),r("div",y,o(e.error),1)):a("",!0),e.item?(i(),r("div",k,[t("h2",null,o(e.item.title),1),t("p",null,"by: "+o(e.item.by),1),t("p",null,"time: "+o(e.item.time),1),t("p",null,"score: "+o(e.item.score),1),t("p",null,"type: "+o(e.item.type),1),t("p",null,[I,t("a",{href:e.item.url},o(e.item.url),9,b)]),t("p",{innerHTML:e.item.text},null,8,S)])):a("",!0)])}}});var $=l(L,[["__scopeId","data-v-2750d908"]]);export{$ as default};