2016-09-01 9 views
0

유성 - 부엌을 서버 측에서 렌더링하는 방법이 있습니까?유성 - 부엌 서버 측 렌더링

현재 모두 자바 스크립트로 렌더링되지만 REST API를 만들 계획이기 때문에 서버 측 렌더링이 필요합니다.

답변

0

meteorhacks를 사용하여 서버 측 렌더링을 수행 할 수 있습니다. ssr + iron : router. 서버 측에서 철로를 만들고 블레이즈 템플릿을 렌더링합니다. 다음은 경로 예입니다.

this.route('home', { 
    where: 'server, 
    path: '/', 
    action: function() { 
     var templateData = {}; 
     var html = SSR.render('templateName', templateData); 
     this.response.writeHead(200, {'Content-Type': 'text/html'}); 
     this.response.write(html); 
     this.response.end(); 
    } 
}); 

나는 https://gameraven.com/에 검색 엔진 최적화에 대한 정적 페이지를 제공하기 위해이 방법을 사용하고 있습니다.

+0

답장을 주신 데릭에게 감사의 말씀을 전합니다. 코드 조각이있는 곳에서이 대답을 확장 할 수 있습니까? – chulian

+0

해당 코드는 server/main.js에 있습니다. 두 패키지의 설명서를 읽으시기 바랍니다. https://github.com/iron-meteor/iron-router 및 https://github.com/meteorhacks/meteor-ssr –

관련 문제