Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗂 Update slugToUrl in article theme #492

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading