Mirror of
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #43 from trueberryless-org/fix-double-content

Fix: double blog content

authored by

trueberryless and committed by
GitHub
036471c0 ef35c9e7

+162 -17
+5
.changeset/fruity-ideas-slide.md
··· 1 + --- 2 + "blog": patch 3 + --- 4 + 5 + Fix: double blog content (custom MarkdownContent override problem)
+88 -15
pnpm-lock.yaml
··· 767 767 '@ungap/structured-clone@1.2.1': 768 768 resolution: {integrity: sha512-fEzPV3hSkSMltkw152tJKNARhOupqbH96MZWyRjNaYZOMIzbrTeQDG+MTc6Mr2pgzFQzFxAfmhGDNP5QK++2ZA==} 769 769 770 + '@ungap/structured-clone@1.3.0': 771 + resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==} 772 + 770 773 '@volar/kit@2.4.11': 771 774 resolution: {integrity: sha512-ups5RKbMzMCr6RKafcCqDRnJhJDNWqo2vfekwOAj6psZ15v5TlcQFQAyokQJ3wZxVkzxrQM+TqTRDENfQEXpmA==} 772 775 peerDependencies: ··· 1252 1255 hast-util-from-parse5@8.0.2: 1253 1256 resolution: {integrity: sha512-SfMzfdAi/zAoZ1KkFEyyeXBn7u/ShQrfd675ZEE9M3qj+PMFX05xubzRyF76CCSJu8au9jgVxDV1+okFvgZU4A==} 1254 1257 1258 + hast-util-from-parse5@8.0.3: 1259 + resolution: {integrity: sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==} 1260 + 1255 1261 hast-util-has-property@3.0.0: 1256 1262 resolution: {integrity: sha512-MNilsvEKLFpV604hwfhVStK0usFY/QmM5zX16bo7EjnAEGofr5YyI37kzopBlZJkHD4t887i+q/C8/tr5Q94cA==} 1257 1263 ··· 1276 1282 hast-util-select@6.0.3: 1277 1283 resolution: {integrity: sha512-OVRQlQ1XuuLP8aFVLYmC2atrfWHS5UD3shonxpnyrjcCkwtvmt/+N6kYJdcY4mkMJhxp4kj2EFIxQ9kvkkt/eQ==} 1278 1284 1285 + hast-util-select@6.0.4: 1286 + resolution: {integrity: sha512-RqGS1ZgI0MwxLaKLDxjprynNzINEkRHY2i8ln4DDjgv9ZhcYVIHN9rlpiYsqtFwrgpYU361SyWDQcGNIBVu3lw==} 1287 + 1279 1288 hast-util-to-estree@3.1.0: 1280 1289 resolution: {integrity: sha512-lfX5g6hqVh9kjS/B9E2gSkvHH4SZNiQFiqWS0x9fENzEl+8W12RqdRxX6d/Cwxi30tPQs3bIO+aolQJNp1bIyw==} 1281 1290 1282 1291 hast-util-to-html@9.0.4: 1283 1292 resolution: {integrity: sha512-wxQzXtdbhiwGAUKrnQJXlOPmHnEehzphwkK7aluUPQ+lEc1xefC8pblMgpp2w5ldBTEfveRIrADcrhGIWrlTDA==} 1284 1293 1294 + hast-util-to-html@9.0.5: 1295 + resolution: {integrity: sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==} 1296 + 1285 1297 hast-util-to-jsx-runtime@2.3.2: 1286 1298 resolution: {integrity: sha512-1ngXYb+V9UT5h+PxNRa1O1FYguZK/XL+gkeqvp7EdHlB9oHUG0eYRo/vY5inBdcqo3RkPMC58/H94HvkbfGdyg==} 1287 1299 ··· 1299 1311 1300 1312 hastscript@9.0.0: 1301 1313 resolution: {integrity: sha512-jzaLBGavEDKHrc5EfFImKN7nZKKBdSLIdGvCwDZ9TfzbF2ffXiov8CKE445L2Z1Ek2t/m4SKQ2j6Ipv7NyUolw==} 1314 + 1315 + hastscript@9.0.1: 1316 + resolution: {integrity: sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==} 1302 1317 1303 1318 html-escaper@3.0.3: 1304 1319 resolution: {integrity: sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==} ··· 1832 1847 resolution: {integrity: sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==} 1833 1848 engines: {node: ^10 || ^12 || >=14} 1834 1849 1835 - postcss@8.5.2: 1836 - resolution: {integrity: sha512-MjOadfU3Ys9KYoX0AdkBlFEF1Vx37uCCeN4ZHnmwm9FfpbsGWMZeBLMmmpY+6Ocqod7mkdZ0DT31OlbsFrLlkA==} 1850 + postcss@8.5.3: 1851 + resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==} 1837 1852 engines: {node: ^10 || ^12 || >=14} 1838 1853 1839 1854 preferred-pm@4.1.1: ··· 1860 1875 1861 1876 property-information@6.5.0: 1862 1877 resolution: {integrity: sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==} 1878 + 1879 + property-information@7.0.0: 1880 + resolution: {integrity: sha512-7D/qOz/+Y4X/rzSB6jKxKUsQnphO046ei8qxG59mtM3RG3DHgTK81HrxrmoDVINJb8NKT5ZsRbwHvQ6B68Iyhg==} 1863 1881 1864 1882 queue-microtask@1.2.3: 1865 1883 resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} ··· 2986 3004 '@expressive-code/core@0.40.2': 2987 3005 dependencies: 2988 3006 '@ctrl/tinycolor': 4.1.0 2989 - hast-util-select: 6.0.3 2990 - hast-util-to-html: 9.0.4 3007 + hast-util-select: 6.0.4 3008 + hast-util-to-html: 9.0.5 2991 3009 hast-util-to-text: 4.0.2 2992 - hastscript: 9.0.0 2993 - postcss: 8.5.2 2994 - postcss-nested: 6.2.0(postcss@8.5.2) 3010 + hastscript: 9.0.1 3011 + postcss: 8.5.3 3012 + postcss-nested: 6.2.0(postcss@8.5.3) 2995 3013 unist-util-visit: 5.0.0 2996 3014 unist-util-visit-parents: 6.0.1 2997 3015 ··· 3329 3347 '@types/unist@3.0.3': {} 3330 3348 3331 3349 '@ungap/structured-clone@1.2.1': {} 3350 + 3351 + '@ungap/structured-clone@1.3.0': {} 3332 3352 3333 3353 '@volar/kit@2.4.11(typescript@5.7.3)': 3334 3354 dependencies: ··· 3961 3981 vfile-location: 5.0.3 3962 3982 web-namespaces: 2.0.1 3963 3983 3984 + hast-util-from-parse5@8.0.3: 3985 + dependencies: 3986 + '@types/hast': 3.0.4 3987 + '@types/unist': 3.0.3 3988 + devlop: 1.1.0 3989 + hastscript: 9.0.1 3990 + property-information: 7.0.0 3991 + vfile: 6.0.3 3992 + vfile-location: 5.0.3 3993 + web-namespaces: 2.0.1 3994 + 3964 3995 hast-util-has-property@3.0.0: 3965 3996 dependencies: 3966 3997 '@types/hast': 3.0.4 ··· 3997 4028 dependencies: 3998 4029 '@types/hast': 3.0.4 3999 4030 '@types/unist': 3.0.3 4000 - '@ungap/structured-clone': 1.2.1 4001 - hast-util-from-parse5: 8.0.2 4031 + '@ungap/structured-clone': 1.3.0 4032 + hast-util-from-parse5: 8.0.3 4002 4033 hast-util-to-parse5: 8.0.0 4003 4034 html-void-elements: 3.0.0 4004 4035 mdast-util-to-hast: 13.2.0 ··· 4027 4058 unist-util-visit: 5.0.0 4028 4059 zwitch: 2.0.4 4029 4060 4061 + hast-util-select@6.0.4: 4062 + dependencies: 4063 + '@types/hast': 3.0.4 4064 + '@types/unist': 3.0.3 4065 + bcp-47-match: 2.0.3 4066 + comma-separated-tokens: 2.0.3 4067 + css-selector-parser: 3.0.5 4068 + devlop: 1.1.0 4069 + direction: 2.0.1 4070 + hast-util-has-property: 3.0.0 4071 + hast-util-to-string: 3.0.1 4072 + hast-util-whitespace: 3.0.0 4073 + nth-check: 2.1.1 4074 + property-information: 7.0.0 4075 + space-separated-tokens: 2.0.2 4076 + unist-util-visit: 5.0.0 4077 + zwitch: 2.0.4 4078 + 4030 4079 hast-util-to-estree@3.1.0: 4031 4080 dependencies: 4032 4081 '@types/estree': 1.0.6 ··· 4062 4111 stringify-entities: 4.0.4 4063 4112 zwitch: 2.0.4 4064 4113 4114 + hast-util-to-html@9.0.5: 4115 + dependencies: 4116 + '@types/hast': 3.0.4 4117 + '@types/unist': 3.0.3 4118 + ccount: 2.0.1 4119 + comma-separated-tokens: 2.0.3 4120 + hast-util-whitespace: 3.0.0 4121 + html-void-elements: 3.0.0 4122 + mdast-util-to-hast: 13.2.0 4123 + property-information: 7.0.0 4124 + space-separated-tokens: 2.0.2 4125 + stringify-entities: 4.0.4 4126 + zwitch: 2.0.4 4127 + 4065 4128 hast-util-to-jsx-runtime@2.3.2: 4066 4129 dependencies: 4067 4130 '@types/estree': 1.0.6 ··· 4113 4176 comma-separated-tokens: 2.0.3 4114 4177 hast-util-parse-selector: 4.0.0 4115 4178 property-information: 6.5.0 4179 + space-separated-tokens: 2.0.2 4180 + 4181 + hastscript@9.0.1: 4182 + dependencies: 4183 + '@types/hast': 3.0.4 4184 + comma-separated-tokens: 2.0.3 4185 + hast-util-parse-selector: 4.0.0 4186 + property-information: 7.0.0 4116 4187 space-separated-tokens: 2.0.2 4117 4188 4118 4189 html-escaper@3.0.3: {} ··· 4867 4938 postcss: 8.5.1 4868 4939 postcss-selector-parser: 6.1.2 4869 4940 4870 - postcss-nested@6.2.0(postcss@8.5.2): 4941 + postcss-nested@6.2.0(postcss@8.5.3): 4871 4942 dependencies: 4872 - postcss: 8.5.2 4943 + postcss: 8.5.3 4873 4944 postcss-selector-parser: 6.1.2 4874 4945 4875 4946 postcss-selector-parser@6.1.2: ··· 4883 4954 picocolors: 1.1.1 4884 4955 source-map-js: 1.2.1 4885 4956 4886 - postcss@8.5.2: 4957 + postcss@8.5.3: 4887 4958 dependencies: 4888 4959 nanoid: 3.3.8 4889 4960 picocolors: 1.1.1 ··· 4909 4980 4910 4981 property-information@6.5.0: {} 4911 4982 4983 + property-information@7.0.0: {} 4984 + 4912 4985 queue-microtask@1.2.3: {} 4913 4986 4914 4987 radix3@1.1.2: {} ··· 5146 5219 dependencies: 5147 5220 color: 4.2.3 5148 5221 detect-libc: 2.0.3 5149 - semver: 7.6.3 5222 + semver: 7.7.1 5150 5223 optionalDependencies: 5151 5224 '@img/sharp-darwin-arm64': 0.33.5 5152 5225 '@img/sharp-darwin-x64': 0.33.5 ··· 5338 5411 5339 5412 typescript-auto-import-cache@0.3.5: 5340 5413 dependencies: 5341 - semver: 7.6.3 5414 + semver: 7.7.1 5342 5415 5343 5416 typescript@5.7.3: {} 5344 5417 ··· 5495 5568 volar-service-typescript@0.0.62(@volar/language-service@2.4.11): 5496 5569 dependencies: 5497 5570 path-browserify: 1.0.1 5498 - semver: 7.6.3 5571 + semver: 7.7.1 5499 5572 typescript-auto-import-cache: 0.3.5 5500 5573 vscode-languageserver-textdocument: 1.0.12 5501 5574 vscode-nls: 5.2.0
+15 -2
starlight/src/components/MarkdownContent.astro
··· 1 1 --- 2 2 import Default from '@astrojs/starlight/components/MarkdownContent.astro' 3 + 3 4 import ImageZoom from 'starlight-image-zoom/components/ImageZoom.astro' 4 5 import StarlightBlogMarkdownContent from 'starlight-blog/components/MarkdownContent.astro' 6 + import { isAnyBlogPostPage } from './utils' 7 + 8 + const { id } = Astro.locals.starlightRoute 5 9 --- 6 10 7 11 <ImageZoom /> 8 - <StarlightBlogMarkdownContent><slot /></StarlightBlogMarkdownContent> 9 - <Default><slot /></Default> 12 + { 13 + isAnyBlogPostPage(id) ? ( 14 + <StarlightBlogMarkdownContent> 15 + <slot /> 16 + </StarlightBlogMarkdownContent> 17 + ) : ( 18 + <Default> 19 + <slot /> 20 + </Default> 21 + ) 22 + }
+54
starlight/src/components/utils.ts
··· 1 + import starlightConfig from "virtual:starlight/user-config"; 2 + import config from "virtual:starlight-blog-config"; 3 + 4 + export function isAnyBlogPostPage(slug: string) { 5 + return ( 6 + new RegExp( 7 + `^${getPathWithLocale( 8 + config.prefix, 9 + getLocaleFromPath(slug) 10 + )}/(?!(\\d+/?|tags/.+|authors/.+)$).+$` 11 + ).exec(slug) !== null 12 + ); 13 + } 14 + 15 + function getPathWithLocale(path: string, locale: Locale): string { 16 + const pathLocale = getLocaleFromPath(path); 17 + if (pathLocale === locale) return path; 18 + locale = locale ?? ""; 19 + if (pathLocale === path) return locale; 20 + if (pathLocale) 21 + return stripTrailingSlash( 22 + path.replace(`${pathLocale}/`, locale ? `${locale}/` : "") 23 + ); 24 + return path 25 + ? `${stripTrailingSlash(locale)}/${stripLeadingSlash(path)}` 26 + : locale; 27 + } 28 + 29 + function getLocaleFromPath(path: string): Locale { 30 + const baseSegment = path.split("/")[0]; 31 + return starlightConfig.locales && 32 + baseSegment && 33 + baseSegment in starlightConfig.locales 34 + ? baseSegment 35 + : undefined; 36 + } 37 + 38 + function stripLeadingSlash(path: string) { 39 + if (!path.startsWith("/")) { 40 + return path; 41 + } 42 + 43 + return path.slice(1); 44 + } 45 + 46 + function stripTrailingSlash(path: string) { 47 + if (!path.endsWith("/")) { 48 + return path; 49 + } 50 + 51 + return path.slice(0, -1); 52 + } 53 + 54 + type Locale = string | undefined;