You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 14, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+27-25Lines changed: 27 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,11 +116,30 @@ Just add a Markdown file under `md/blog/` to create a new blog post:
116
116
117
117
## Google Analytics
118
118
119
-
Just add your Google Analytics ID (e.g. e.g. 'UA-999999999-1') to `globals.ts` and Devii will automatically add the appropriate Google Analytics snippet to your site. Go to `/pages/_app.ts` to see how this works or customize this behavior.
119
+
Just add your Google Analytics ID (e.g. 'UA-999999999-1') to `globals.ts` and Devii will automatically add the appropriate Google Analytics snippet to your site. Go to `/pages/_app.ts` to see how this works or customize this behavior.
120
120
121
121
## Frontmatter support
122
122
123
-
Every Markdown file can include a "frontmatter block" containing various metadata. This is the frontmatter blog from the sample blog post (`md/blog/test.md`):
123
+
Every Markdown file can include a "frontmatter block" containing various metadata. Devii provides a `loadPost` utility that loads a Markdown file, parses it's frontmatter metadata, and returns a structured `PostData` object:
124
+
125
+
```ts
126
+
typePostData= {
127
+
path:string;
128
+
title?:string;
129
+
subtitle?:string;
130
+
description?:string; // used for SEO
131
+
canonicalUrl?:string; // used for SEO
132
+
datePublished?:number; // Unix timestamp
133
+
author?:string;
134
+
authorPhoto?:string;
135
+
authorHandle?:string; // twitter handle
136
+
tags?:string[];
137
+
bannerPhoto?:string;
138
+
thumbnailPhoto?:string;
139
+
};
140
+
```
141
+
142
+
For example, here is the frontmatter blog from the sample blog post (`md/blog/the-ultimate-tech-stack.md`):
124
143
125
144
```
126
145
---
@@ -137,23 +156,6 @@ thumbnailPhoto: /brook.jpg
137
156
---
138
157
```
139
158
140
-
This metadata will be loaded and parsed into a TypeScript object with the following type.
There are a few utility functions in `loader.ts` that Devii uses.
209
+
There are a few utility functions in `loader.ts` that Devii uses. All functions are _async_! All functions accept a _relative_ path which is expected to be \_relative to the `md/` directory. For instance `loadPost('blog/test.md'`) would load `/md/blog/test.md`.
208
210
209
-
-`loadPost` loads/parses a Markdown file and returns a `PostData`. It takes on argument, the name of a file in the `md/` directory. For instance `loadPost('about.md')` would load `/md/about.md` and `loadPost('blog/test.md'`) would load `/md/blog/test.md`.
210
-
-`loadBlogPosts`: loads/parses all the files in `/md/blog/`. Returns `PostData[]`. Used in `index.tsx` to read a list of all published blog posts.
211
-
-`loadMarkdownFile`: loads a Markdown file but doesn't parse it. Returns the string content. Useful if you want to implement certain parts of a page in Markdown and other parts in React.
212
-
-`loadMarkdownFiles`: accepts a [glob](https://docs.python.org/3/library/glob.html) pattern and loads all the files inside `/md/` whose names match the pattern. Used internally by `loadBlogPosts`.
211
+
-`loadPost` loads/parses a Markdown file and returns a `PostData`
212
+
-`loadBlogPosts`: loads/parses all the files in `/md/blog/`. Returns `PostData[]`. Used in `index.tsx` to load/render a list of all published blog posts
213
+
-`loadMarkdownFile`: loads a Markdown file but doesn't parse it. Returns the string content. Useful if you want to implement some parts of a page in Markdown and other parts in React
214
+
-`loadMarkdownFiles`: accepts a [glob](https://docs.python.org/3/library/glob.html) pattern and loads all the files inside `/md/` whose names match the pattern. Used internally by `loadBlogPosts`
213
215
214
216
## Static generation
215
217
216
218
You can generate a fully static version of your site using `yarn build && yarn export`. This step is entirely powered by Next.js. The static site is exported to the `out` directory.
217
219
218
-
After its generated, use your static file hosting service of choice (Firebase Hosting, Amazon S3, Vercel) to deploy your site.
220
+
After it's generated, use your static file hosting service of choice (Vercel, Netlify, Firebase Hosting, Amazon S3) to deploy your site.
0 commit comments