Skip to content

Commit 1b0681e

Browse files
authored
Merge pull request #356 from rejas/linking
Fix internal link rewriting
2 parents 98dacf8 + 6180cbd commit 1b0681e

18 files changed

Lines changed: 242 additions & 234 deletions

.vitepress/theme/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import "./style.css";
77
import BackToTopButton from "@miletorix/vitepress-back-to-top-button";
88
import "@miletorix/vitepress-back-to-top-button/style.css";
99

10+
function rewrite(path: string): string | null {
11+
// Example: VuePress legacy prefix
12+
if (path.startsWith("/development/"))
13+
return path.replace("/development/", "/module-development/");
14+
15+
return null;
16+
}
17+
1018
export default {
1119
extends: DefaultTheme,
1220
Layout: () => {
@@ -16,5 +24,13 @@ export default {
1624
},
1725
enhanceApp({ app, router, siteData }) {
1826
BackToTopButton(app);
27+
router.onBeforeRouteChange = (to) => {
28+
const next = rewrite(to);
29+
if (next && next !== to) {
30+
// Replace instead of push: avoids back-button loops
31+
router.go(next);
32+
return false; // cancel original navigation
33+
}
34+
};
1935
},
2036
} satisfies Theme;

configuration/introduction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
};
2222
```
2323

24-
See [module configuration](/modules/configuration.md) for more information
25-
and examples.
24+
See [module configuration](/modules/configuration) for more information and
25+
examples.
2626

2727
4. Run your magic mirror. Refer back to
28-
[installation](/getting-started/installation.md) if you're not sure how to do
28+
[installation](/getting-started/installation) if you're not sure how to do
2929
so.
3030

3131
## More useful configuration of your MagicMirror
@@ -56,13 +56,13 @@ The following properties can be configured, place them above the modules item:
5656
| `language` | The language of the interface. (Note: Not all elements will be localized.) Possible values are `en`, `nl`, `ru`, `fr`, etc. for the full list see: [List of ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | `en` |
5757
| `timeFormat` | The form of time notation that will be used. Possible values are `12` or `24`. | 24 |
5858
| `units` | The units that will be used in the default weather modules. Possible values are `metric` or `imperial`. | `metric` |
59-
| `electronOptions` | An optional array of Electron (browser) options. This allows configuration of e.g. the browser screen size and position (example: `electronOptions: { fullscreen: false, width: 800, height: 600 }`). Kiosk mode can be enabled by setting `kiosk: true`, `autoHideMenuBar: false` and `fullscreen: false`. More options can be found [here](https://github.com/electron/electron/blob/master/docs/api/browser-window.md). This will most likely be used in advanced installations, below. | [] |
59+
| `electronOptions` | An optional array of Electron (browser) options. This allows configuration of e.g. the browser screen size and position (example: `electronOptions: { fullscreen: false, width: 800, height: 600 }`). Kiosk mode can be enabled by setting `kiosk: true`, `autoHideMenuBar: false` and `fullscreen: false`. More options can be found [here](https://github.com/electron/electron/blob/master/docs/api/browser-window). This will most likely be used in advanced installations, below. | [] |
6060
| `electronSwitches` | An optional array of Electron switches. This allows configuration of electron app itself. <br> This properties will not affect the `serveronly` mode. Usually normal `MM` users don't need this property, but if you are a hard-core hacker, you might need this to handle Electron itself over `MagicMirror` provides. More options can be found [here](https://www.electronjs.org/docs/latest/api/command-line-switches) (Not all available switches are described there.)<br>example:`electronSwitches:["enable-transparent-visuals", "disable-gpu"];` | [] |
6161
| `customCss` | The path of the `custom.css` stylesheet. The default is `css/custom.css`. | `css/custom.css` |
62-
| `watchTargets` | An optional array of file paths to monitor when using `node --run server:watch`. When any of these files change, the server automatically restarts and connected browsers reload. Particularly useful when frequently modifying `config.js`, `custom.css`, or module files during development or setup. Example: `watchTargets: ["config/config.js", "css/custom.css", "modules/MMM-MyModule/MMM-MyModule.js"]`. See [Development Mode](/core-development/debugging.md#watch-mode-with-auto-reload) for more details. | `undefined` |
62+
| `watchTargets` | An optional array of file paths to monitor when using `node --run server:watch`. When any of these files change, the server automatically restarts and connected browsers reload. Particularly useful when frequently modifying `config.js`, `custom.css`, or module files during development or setup. Example: `watchTargets: ["config/config.js", "css/custom.css", "modules/MMM-MyModule/MMM-MyModule.js"]`. See [Development Mode](/core-development/debugging#watch-mode-with-auto-reload) for more details. | `undefined` |
6363

6464
After the above options, you will then add modules. See
65-
[module configuration](/modules/configuration.md) for more information.
65+
[module configuration](/modules/configuration) for more information.
6666

6767
### Advanced configuration and frequently asked how to configure examples
6868

core-development/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This documentation describes core MagicMirror² development.
99
## General
1010

1111
MagicMirror² is a community-driven development effort, and
12-
[contributions](/about/contributing.md) are welcome!
12+
[contributions](/about/contributing) are welcome!
1313

1414
In general, new features and bug fixes should be tracked against an
1515
[issue in the MagicMirror repo](https://github.com/MagicMirrorOrg/MagicMirror/issues).

enhanceApp.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

getting-started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ controlled by settings inside the `config/config.js` file by interface and ip:
143143
- Change `ipWhitelist` to the list of IP's you want to allow to connect
144144

145145
Sample Configuration below
146-
[and link to full configuration options](/configuration/introduction.md)
146+
[and link to full configuration options](/configuration/introduction)
147147

148148
```js
149149
let config = {

getting-started/requirements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Raspberry Pi.
99
_Electron_, the app wrapper around MagicMirror², only supports the Raspberry Pi
1010
2, 3, 4 & 5. The Raspberry Pi 0/1 is currently **not** supported. If you want to
1111
run this on a Raspberry Pi 1, use the
12-
[server only](/getting-started/installation.md#server-only) feature and setup a
12+
[server only](/getting-started/installation#server-only) feature and setup a
1313
fullscreen browser yourself. (Yes, people have managed to run MM² also on a Pi0,
1414
so if you insist, search in the forums.)
1515

@@ -20,7 +20,7 @@ You will need to install the latest full version of
2020
Raspbian).
2121

2222
If you want to run the software on other Operating Systems, take a look at
23-
[this section](/getting-started/installation.md#alternative-installation-methods)
23+
[this section](/getting-started/installation#alternative-installation-methods)
2424

2525
::: warning NOTE You **do** need a desktop environment to run Electron!
2626

module-development/core-module-file.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ system calls the getDom method. This method should therefore return a dom
206206
object.
207207

208208
Read more about Rendering Components
209-
[in the Rendering Component documentation](/module-development/rendering.md).
209+
[in the Rendering Component documentation](/module-development/rendering).
210210

211211
**Example:**
212212

@@ -232,7 +232,7 @@ An example of a default module that uses this method is
232232
[newsfeed](https://github.com/MagicMirrorOrg/MagicMirror/blob/master/modules/default/newsfeed/newsfeed.js).
233233

234234
Read more about Rendering Components
235-
[in the Rendering Component documentation](/module-development/rendering.md).
235+
[in the Rendering Component documentation](/module-development/rendering).
236236

237237
**Example:**
238238

@@ -283,7 +283,7 @@ getTemplateData: function() {
283283
Whenever the MagicMirror needs to update the information on screen (because it
284284
starts, or because your module asked a refresh using `this.updateDom()`), the
285285
system calls the getHeader method to retrieve the module's header. This method
286-
should therefor return a string. If this method is not subclassed, this function
286+
should therefore return a string. If this method is not subclassed, this function
287287
will return the user's configured header.
288288

289289
If you want to use the original user's configured header, reference
@@ -394,9 +394,9 @@ the content update will be animated, but only if the content will really change.
394394

395395
Note that the rendering of the updated dom on the screen will happen
396396
asynchronously. You can listen for the
397-
[`DOM_OBJECTS_UPDATED` notification](/module-development/notifications.md) to
398-
know when the rendering is complete and the new dom is safe to interact with.
399-
This notification only fires if the content will really change.
397+
[`DOM_OBJECTS_UPDATED` notification](/module-development/notifications) to know
398+
when the rendering is complete and the new dom is safe to interact with. This
399+
notification only fires if the content will really change.
400400

401401
**Example:**
402402

@@ -422,10 +422,10 @@ module needs to be updated
422422

423423
**animate Object**
424424

425-
| animate | type | description |
426-
| ------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
427-
| in | String | Animate name when module will be shown (after dom update), it will use an `animateIn` type name (see [Animation Guide](/modules/animate.md#animatein)) |
428-
| out | String | Animate name when module will be hidden (before dom update), it will use an `animateOut` type name (see [Animation Guide](/modules/animate.md#animateout)) |
425+
| animate | type | description |
426+
| ------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
427+
| in | String | Animate name when module will be shown (after dom update), it will use an `animateIn` type name (see [Animation Guide](/modules/animate#animatein)) |
428+
| out | String | Animate name when module will be hidden (before dom update), it will use an `animateOut` type name (see [Animation Guide](/modules/animate#animateout)) |
429429

430430
**Example:**
431431

@@ -499,7 +499,7 @@ Possible configurable options:
499499

500500
- `animate` - String - (_Introduced in version: 2.25.0._) Hide the module with a
501501
special animate. It will use an `animateOut` type name. All animations name
502-
are available in [Animation Guide](/modules/animate.md#animateout)
502+
are available in [Animation Guide](/modules/animate#animateout)
503503

504504
::: warning Notes:
505505

@@ -542,7 +542,7 @@ Possible configurable options:
542542
object, if specified in the options (_Introduced in version: 2.15.0_).
543543
- `animate` - String - (_Introduced in version: 2.25.0._) Show the module with a
544544
special animation. It will use an `animateIn` type name. All animations name
545-
are available in [Animation Guide](/modules/animate.md#animatein)
545+
are available in [Animation Guide](/modules/animate#animatein)
546546

547547
::: warning Notes:
548548

module-development/helper-methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ for more info.
2020

2121
**Note:** This method returns an empty array if not all modules are started yet.
2222
Wait for the `ALL_MODULES_STARTED`
23-
[notification](/module-development/core-module-file.md#notificationreceived-notification-payload-sender).
23+
[notification](/module-development/core-module-file#notificationreceived-notification-payload-sender).
2424

2525
#### `.withClass(classnames)`
2626

module-development/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ information in your README file.**
2323
it free?)
2424
- **Do not use `new Date()` for the current timestamp, instead prefer
2525
`new Date(Date.now())` as it can be more
26-
[easily overridden for debugging](/core-development/debugging.md#date)**.
26+
[easily overridden for debugging](/core-development/debugging#date)**.
2727

2828
Surely this also help you get better recognition and feedback for your work.
2929

module-development/node-helper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ When this method is called, it has 2 arguments:
130130

131131
**Note:** The socket connection is established as soon as the module sends its
132132
first message using
133-
[sendSocketNotification](/module-development/core-module-file.md#this-sendsocketnotification-notification-payload).
133+
[sendSocketNotification](/module-development/core-module-file#this-sendsocketnotification-notification-payload).
134134

135135
**Example:**
136136

0 commit comments

Comments
 (0)