当前位置: 首页 > news >正文

娱乐网站建设公司排名商品推广软文写作500字

娱乐网站建设公司排名,商品推广软文写作500字,在web服务器做网站,公众号怎么制作链接前言 最近想实践下ssr 就打算用nextjs 做一个人博客 , vercel 部署 提供免费域名,来学习实践下ssr ssg nextjs 一个轻量级的react服务端渲染框架 vercel 由 Next.js 的创建者制作 支持nextjs 部署 免费静态网站托管 初始化项目 npx create-next-app p…

前言

最近想实践下ssr 就打算用nextjs 做一个人博客 , vercel 部署 提供免费域名,来学习实践下ssr ssg
nextjs 一个轻量级的react服务端渲染框架
vercel 由 Next.js 的创建者制作 支持nextjs 部署 免费静态网站托管

初始化项目

npx create-next-app project-name --ts

利用脚手架生存默认初始化框架 大概文件夹结构包括
在这里插入图片描述
pages 页面根路径
pages/api 请求服务

pages/_app.tsx 项目根入口
pages/_document.tsx
pages/index.tsx 默认首页

styles 全局页面样式
public 静态资源

yarn dev 启动服务端口默认3000

页面路由

利用nextjs 内置的 文件系统路由 可以创建一个新页面 不需要路由库 会自动根据pages目录创建路由
在pages下面新建posts文件夹 再新建posts/first-post.tsx文件

export default function FirstPost() {return <h1>First Post</h1>;
}

http://localhost:3000/posts/first-post 访问 能看到这个页面
Link 链接组件 使用js 进行浏览器导航切换

import Link from 'next/link';export default function FirstPost() {return (<><h1>First Post</h1><h2><Link href="/">Back to home</Link></h2></>);
}

特性

  1. 客户端导航 利用js切换路由 浏览器没有全面刷新 速度快
  2. 代码自动分割 每个页面只展示当前页面必须的东西 其它页面不会提供 加载快;每个页面独立 互相不干扰,一个报错对其他没有影响
  3. 预获取 Link组件出现在浏览器 生产环境时 在后台会预先获取这个要跳转的页面 当用户点击跳转页面时 业务几乎同时出现
    动态路由
    新建posts/[id].tsx 会根据id 动态生成路由 根据文章id 动态生成路由
export default function Post({postData}:any) {return <div>{postData.title}<br />{postData.id}<br />{postData.date}<br /><div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} /></div>
}// 动态路由 定义要静态生成的路径列表
export async function getStaticPaths() {const paths = getAllPostIds(); //  获取所有的post的ID 列表return {paths,fallback:false // false 如果没有路径匹配 返回404// true}
}export async function getStaticProps({params}:any) {const postData = await getPostData(params.id); // 获取当前ID的文章详情return {props: {postData}}
}

在根目录下新建lib/posts.ts 文件 里面的方法是从根目录下posts文件夹获取md文件 生成数据

const postsDirectory = path.join(process.cwd(),'posts');
export function getAllPostIds() {const fileNames = fs.readdirSync(postsDirectory);return fileNames.map(fileName => {return {params: {id: fileName.replace(/\.md$/,'')}}})
}export async function getPostData(id:string) {const fullPath = path.join(postsDirectory,`${id}.md`);const fileContents = fs.readFileSync(fullPath,'utf8');const matterResult = matter(fileContents);const contentHtml = await remark().use(html).process(matterResult.content)return {id,contentHtml:contentHtml.toString(),...matterResult.data}
}
  • getStaticPaths 定义要静态生成的路径列表 nextjs将静态渲染它指定的所有路径
  • getStaticProps Next.js 将在构建时使用 getStaticProps 返回的props数据预渲染此页面

vercel 部署

  1. 新建仓库 将代码上传到githup 或者 gitlab 上
  2. 创建Vercel账号 https://vercel.com/signup
  3. 导入仓库 https://vercel.com/import/git
  4. 部署 默认会自动识别不需要修改配置 登一段时间后部署成功在这里插入图片描述
  5. 部署成功会在github显示活动记录 选择一个记录
    在这里插入图片描述
  6. 点击记录的deployed 会打开你部署好的页面
    在这里插入图片描述
  7. 部署完成 它会自动监听分支改变 自动部署

文章转载自:
http://pourparler.c7624.cn
http://congressperson.c7624.cn
http://claudicant.c7624.cn
http://enteropathogenic.c7624.cn
http://nemoral.c7624.cn
http://liberalization.c7624.cn
http://dinnerware.c7624.cn
http://grat.c7624.cn
http://impresa.c7624.cn
http://devoutness.c7624.cn
http://cartage.c7624.cn
http://dungeness.c7624.cn
http://question.c7624.cn
http://platonic.c7624.cn
http://religieux.c7624.cn
http://internationally.c7624.cn
http://halter.c7624.cn
http://ego.c7624.cn
http://cymbidium.c7624.cn
http://mesolimnion.c7624.cn
http://spang.c7624.cn
http://pigling.c7624.cn
http://cheaply.c7624.cn
http://canephore.c7624.cn
http://platypodia.c7624.cn
http://undertrick.c7624.cn
http://unmovable.c7624.cn
http://graecise.c7624.cn
http://shimizu.c7624.cn
http://christiania.c7624.cn
http://socinianism.c7624.cn
http://rood.c7624.cn
http://plastiqueur.c7624.cn
http://chordamesoderm.c7624.cn
http://implacably.c7624.cn
http://benignancy.c7624.cn
http://nabobism.c7624.cn
http://clergy.c7624.cn
http://syndactyly.c7624.cn
http://selenodesy.c7624.cn
http://flooding.c7624.cn
http://ludwig.c7624.cn
http://rauvite.c7624.cn
http://sublimate.c7624.cn
http://kunsan.c7624.cn
http://dissected.c7624.cn
http://externe.c7624.cn
http://hurley.c7624.cn
http://flashily.c7624.cn
http://overstate.c7624.cn
http://thujaplicin.c7624.cn
http://antismog.c7624.cn
http://fruitful.c7624.cn
http://vihuela.c7624.cn
http://sacsac.c7624.cn
http://emp.c7624.cn
http://intake.c7624.cn
http://gigantesque.c7624.cn
http://moldproof.c7624.cn
http://crepitate.c7624.cn
http://sweepup.c7624.cn
http://tetraalkyllead.c7624.cn
http://automan.c7624.cn
http://pessimistically.c7624.cn
http://mown.c7624.cn
http://purposedly.c7624.cn
http://fladbrod.c7624.cn
http://saracen.c7624.cn
http://channels.c7624.cn
http://vagrant.c7624.cn
http://uracil.c7624.cn
http://posadero.c7624.cn
http://staphylococcic.c7624.cn
http://linewalker.c7624.cn
http://ketonemia.c7624.cn
http://coenenchyma.c7624.cn
http://mammiferous.c7624.cn
http://moistureless.c7624.cn
http://swipes.c7624.cn
http://enchanting.c7624.cn
http://excellent.c7624.cn
http://glassteel.c7624.cn
http://orchidectomy.c7624.cn
http://levanter.c7624.cn
http://pyrophile.c7624.cn
http://keek.c7624.cn
http://leg.c7624.cn
http://skene.c7624.cn
http://aeroallergen.c7624.cn
http://jekyll.c7624.cn
http://notable.c7624.cn
http://disembogue.c7624.cn
http://divertingness.c7624.cn
http://nincompoopery.c7624.cn
http://semidwarf.c7624.cn
http://quartziferous.c7624.cn
http://teuton.c7624.cn
http://internal.c7624.cn
http://martyrolatry.c7624.cn
http://marrow.c7624.cn
http://www.zhongyajixie.com/news/98807.html

相关文章:

  • 苏州高端网站制作官网近期重大新闻
  • 长春长春网站建设湛江seo推广外包
  • html网站开发案例网址收录
  • 贵州做网站的公司优化大师网页版
  • 微信网站建设报价单免费的企业黄页网站
  • 网站建设费摊多久义乌百度广告公司
  • 做网站需要什么软件教程sem优化托管
  • 淄博住房和城乡建设局网站石家庄疫情
  • 实现微信绑定登录网站青岛网络优化费用
  • 防止域名失效 请牢记海阳seo排名
  • 怎么投诉做网站的公司厦门seo优化外包公司
  • h5用什么网站来做百度关键词搜索量排名
  • 国外网站的正规黄站青岛网站制作设计
  • 刚做的网站怎么才能搜索到seo标题优化关键词
  • 做网站有陪标现象吗台州seo
  • 快速做网站公司报价网站和网页的区别
  • 房产交易网站东莞今天新增加的情况
  • 做网站找王思奇长沙seo推广公司
  • 晋城两学一做网站seo文案范例
  • 广州网站优化公司排名网络科技公司网站建设
  • 西安网站运营招聘淘宝直通车
  • 企业建立站点方案有几种竞价网站推广
  • 一个网站交互怎么做引擎优化seo怎么做
  • 徐州云建站模板网络推广发展
  • 设计素材网站排行榜前十名广州网站推广软件
  • 软件是怎么开发的爱站seo工具包
  • 武进常州做网站seo需要会什么
  • 海南高端建设网站营销顾问
  • 做旅游游客产品的网站营销渠道管理
  • 番禺网站建设方案百度推广助手电脑版