Skip to content

Commit

Permalink
🗂 Update slugToUrl in article theme (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkoch authored Oct 30, 2024
1 parent e498cf1 commit cc7e94b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/light-donkeys-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@myst-theme/article': patch
'@myst-theme/site': patch
---

Update slugToUrl in article theme
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"changeset": "changeset",
"version": "changeset version && npm install",
"publish": "npm run clean && npm run build -- --force && changeset publish && git push --follow-tags",
"publish:ci": "npm run clean && npm run build && changeset publish && git push --follow-tags"
"publish:ci": "npm run clean && npm run build && changeset publish && git push --follow-tags",
"bump:myst:packages": "npx npm-upgrade-monorepo -w 'packages/*' 'myst-* @myst-theme/*'",
"bump:myst:themes": "npx npm-upgrade-monorepo -w 'themes/*' 'myst-* @myst-theme/*'",
"bump:myst": "npm run bump:myst:packages && npm run bump:myst:themes"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
Expand All @@ -52,6 +55,5 @@
"node": ">=14.0.0"
},
"packageManager": "[email protected]",
"dependencies": {
}
"dependencies": {}
}
3 changes: 2 additions & 1 deletion packages/site/src/components/DocumentOutline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { RefObject } from 'react';
import { DocumentChartBarIcon } from '@heroicons/react/24/outline';
import { ChevronRightIcon } from '@heroicons/react/24/solid';
import * as Collapsible from '@radix-ui/react-collapsible';
import { slugToUrl } from 'myst-common';

const SELECTOR = [1, 2, 3, 4].map((n) => `main h${n}`).join(', ');

Expand Down Expand Up @@ -443,7 +444,7 @@ export function SupportingDocuments() {
return (
<li key={p.slug}>
<NavLink
to={withBaseurl(`/${p.slug}#main`, baseurl)}
to={withBaseurl(`/${slugToUrl(p.slug)}#main`, baseurl)}
prefetch="intent"
className={({ isActive }) =>
classNames('no-underline flex self-center hover:text-blue-700', {
Expand Down
3 changes: 2 additions & 1 deletion themes/article/app/utils/loaders.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fetch from 'node-fetch';
import { redirect } from '@remix-run/node';
import type { SiteManifest } from 'myst-config';
import { slugToUrl } from 'myst-common';
import {
type PageLoader,
getFooterLinks,
Expand Down Expand Up @@ -65,7 +66,7 @@ export async function getPage(
throw redirect(projectName ? `/${projectName}` : '/');
}
if (opts.slug?.endsWith('.index') && opts.redirect) {
const newSlug = opts.slug.slice(0, -6);
const newSlug = slugToUrl(opts.slug);
throw redirect(projectName ? `/${projectName}/${newSlug}` : `/${newSlug}`);
}
let slug = opts.loadIndexPage || opts.slug == null ? project.index : opts.slug;
Expand Down

0 comments on commit cc7e94b

Please sign in to comment.