diff --git a/routes/api/blog/index.js b/routes/api/blog-posts.js similarity index 85% rename from routes/api/blog/index.js rename to routes/api/blog-posts.js index 4c10788..7120e67 100644 --- a/routes/api/blog/index.js +++ b/routes/api/blog-posts.js @@ -1,4 +1,4 @@ -import posts from './_posts.js'; +import posts from './blog/_posts.js'; const contents = JSON.stringify(posts.map(post => { return { diff --git a/routes/api/blog/_posts.js b/routes/api/blog/_posts.js index 7fe65c5..0864315 100644 --- a/routes/api/blog/_posts.js +++ b/routes/api/blog/_posts.js @@ -70,7 +70,7 @@ const posts = [
routes/blog/[slug].htmlroutes directory. These are just .js files that export functions corresponding to HTTP methods, and receive Express request and response objects as arguments. This makes it very easy to, for example, add a JSON API such as the one powering this very page (look in routes/api/blog)routes directory. These are just .js files that export functions corresponding to HTTP methods, and receive Express request and response objects as arguments. This makes it very easy to, for example, add a JSON API such as the one powering this very page (look in routes/api/blog-posts)<a> elements, rather than framework-specific <Link> components. That means, for example, that this link right here, despite being inside a blob of HTML, works with the router as you'd expect.