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

🗂 Add site option to include folder structure in url paths #1601

Merged
merged 10 commits into from
Oct 24, 2024

Conversation

fwkoch
Copy link
Collaborator

@fwkoch fwkoch commented Oct 23, 2024

This PR adds an option to support nested folder structure in URLs. See #670

This uses an option at the site level of your myst.yml - site.options.url_folders: true. Given this option, slugs are computed to contain dot-delimited folder structure (as opposed to the previous behavior where slugs were computed entirely based on filename). Consuming these new slugs with folders requires an updated myst theme, see jupyter-book/myst-theme#489 (without the updated theme, the dots in the slugs will just show up in your MyST site; with the updated theme, your site URLs will have slashes instead of dots)

Copy link

changeset-bot bot commented Oct 23, 2024

🦋 Changeset detected

Latest commit: 11889fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
myst-common Patch
myst-cli Patch
mystmd Patch
myst-config Patch
myst-frontmatter Patch
myst-spec-ext Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -57,9 +57,13 @@ export async function loadProjectFromDisk(
let newProject: Omit<LocalProject, 'bibliography'> | undefined;
let { index, writeTOC } = opts || {};
let legacyToc = false;
const siteConfig = selectors.selectLocalSiteConfig(state, path);
const urlFolders = !!siteConfig?.options?.url_folders;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to take suggestions about a better name for this option...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fwkoch do we have a policy about snake_case vs pascalCase for frontmatter/config item names?

Copy link
Contributor

@stevejpurves stevejpurves Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake case for items in config data files (.yml), and so they also leak into typescript in places. Everything else is PascalCase (classes) / camelCase (fns, vars).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do site.folders and get around it!

@stevejpurves
Copy link
Contributor

@fwkoch seems like there will be no impact on the location field in the output mdast and in source on notebook outputs?

@fwkoch
Copy link
Collaborator Author

fwkoch commented Oct 23, 2024

@stevejpurves - yeah, location and source should be unchanged - these are still the relative file paths.

packages/myst-cli/src/process/mdast.ts Outdated Show resolved Hide resolved
packages/myst-cli/src/process/site.ts Outdated Show resolved Hide resolved
@@ -57,9 +57,13 @@ export async function loadProjectFromDisk(
let newProject: Omit<LocalProject, 'bibliography'> | undefined;
let { index, writeTOC } = opts || {};
let legacyToc = false;
const siteConfig = selectors.selectLocalSiteConfig(state, path);
const urlFolders = !!siteConfig?.options?.url_folders;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do site.folders and get around it!

@rowanc1 rowanc1 merged commit 2bce565 into main Oct 24, 2024
7 checks passed
@rowanc1 rowanc1 deleted the feat/folder-structure branch October 24, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants