Skip to content

How can I implement pretty urls in fresh? #997

Closed Answered by dnk8n
dnk8n asked this question in Q&A
Discussion options

You must be logged in to vote

I figured some things out, see here https://github.com/dnk8n/rethinkcode/tree/integrate-lume

It is currently working at https://rethinkcode--integrate-lume.deno.dev/

e.g. https://rethinkcode--integrate-lume.deno.dev/projects/mercede-benz

Prettier site to come!

The main change happens at routes/_middleware.ts:

import { MiddlewareHandlerContext } from "$fresh/server.ts";

interface State {
  data: string;
}

export async function handler(
  req: Request,
  ctx: MiddlewareHandlerContext<State>,
) {
  const filePath = "_site" + new URL(req.url).pathname + "/index.html";
  let fileSize;
  try {
    fileSize = (await Deno.stat(filePath)).size;
  } catch (e) {
    if (e instanceof Deno.errors.No…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marvinhagemeister
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant