From f53709a779667bb36ff7ed2cb2994bc820b4e8d9 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 11 Aug 2024 13:20:28 -0300 Subject: [PATCH] [i18n-ignore] fix(plugins): preserve permission anchor links (#2530) --- astro.config.mjs | 5 ++++- src/components/PluginPermissions.astro | 10 +++++++++- .../docs/learn/Security/using-plugin-permissions.mdx | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index b37c279740..e917e0f473 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -75,7 +75,10 @@ export default defineConfig({ }, }), starlightBlog({ authors }), - starlightLinksValidator({ errorOnRelativeLinks: false }), + starlightLinksValidator({ + errorOnRelativeLinks: false, + exclude: ['/plugin/*/#default-permission', '/plugin/*/#permission-table'], + }), ], title: 'Tauri', description: 'The cross-platform app building toolkit', diff --git a/src/components/PluginPermissions.astro b/src/components/PluginPermissions.astro index 19c4b3ea07..732c56f1d7 100644 --- a/src/components/PluginPermissions.astro +++ b/src/components/PluginPermissions.astro @@ -34,6 +34,14 @@ const md = await createMarkdownProcessor(); const pageContent: string = await importMDX(plugin); const content = await md.render(pageContent); +let code = content.code; + +for (const heading of ['h1', 'h2', 'h3', 'h4']) { + code = code.replace( + new RegExp(`<${heading} id="([A-Za-z0-9\-]+)">([A-Za-z0-9\- ]+)`), + `<${heading} id="$1">$2` + ); +} --- - + diff --git a/src/content/docs/learn/Security/using-plugin-permissions.mdx b/src/content/docs/learn/Security/using-plugin-permissions.mdx index cd932d8429..b6329ecdef 100644 --- a/src/content/docs/learn/Security/using-plugin-permissions.mdx +++ b/src/content/docs/learn/Security/using-plugin-permissions.mdx @@ -98,7 +98,7 @@ permissions are used. In the case of official maintained plugins you can find a rendered description in the documentation - (eg. [fs default](/plugin/file-system/#permissions)). + (eg. [fs default](/plugin/file-system/#default-permission)). In case you are figuring this out for a community plugin you need to check out the source code of the plugin. @@ -147,7 +147,7 @@ permissions are used. The `fs` plugin has autogenerated permissions which will disable or enable individual commands and allow or disable global scopes. - These can be found in the [documentation](/plugin/file-system/#permissions) + These can be found in the [documentation](/plugin/file-system/#permission-table) or in the source code of the plugin (`fs/permissions/autogenerated`). Let us assume we want to enable writing to a text file `test.txt`