このチュートリアルでは、マーケティングページ、ブログ、FAQセクションを備えたCMSを搭載したAngularアプリケーションの構築を実証しています。これらはすべてコンテンツAPIによって駆動されます。 サーバーのセットアップは必要ありません!
重要な利点:
Angular CLIとButterCMSのシームレスな統合を使用したAngular CLIのインストール:
npm install -g @angular/cli
ng new my-angular-cms --style=scss cd my-angular-cms
npm install --save @angular/material @angular/cdk @angular/animations buttercms
src/app/_services/buttercms.service.ts
import * as Butter from 'buttercms'; export const butterService = Butter('YOUR_API_TOKEN'); // Replace with your API token
src/app/app.component.ts
import { Component, OnInit } from '@angular/core'; import { butterService } from './_services/buttercms.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent implements OnInit { posts: any[] = []; headline: string = ''; constructor(private butter: butterService) {} ngOnInit(): void { this.fetchPosts(); this.fetchHeadline(); } fetchPosts() { this.butter.post.list({ page: 1, page_size: 10 }) .then((res) => { this.posts = res.data.data; }); } fetchHeadline() { this.butter.content.retrieve(['homepage_headline']) .then((res) => { this.headline = res.data.data.homepage_headline; }); } }
以上がサーバーレスのCMS搭載の角度アプリケーションを構築する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。