-
Notifications
You must be signed in to change notification settings - Fork 80
Fix Markdown content negotiation #528
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
base: main
Are you sure you want to change the base?
Changes from all commits
886a6fd
ec6eed7
acf367e
2196157
20dd8ae
8df07eb
4cdaad5
5bab378
cf8b92d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,6 @@ disable = [ | |
| "MD046", | ||
| # for some reason required for tables | ||
| "MD058", | ||
| # indentations in lists | ||
| "MD077", | ||
| ] | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||
| --- | ||||||||||||||||||||
| import { SEO } from "astro-seo"; | ||||||||||||||||||||
| import { plainText } from "../lib/utils"; | ||||||||||||||||||||
| import { site } from "../site"; | ||||||||||||||||||||
| import Posthog from "./Posthog.astro"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -8,14 +9,19 @@ type Props = { | |||||||||||||||||||
| description?: string; | ||||||||||||||||||||
| tags?: string[]; | ||||||||||||||||||||
| author?: string; | ||||||||||||||||||||
| markdownNegotiation?: boolean; | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const root = Astro.site!.toString(); | ||||||||||||||||||||
| const canonical = new URL(Astro.url.pathname, root); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const { title: siteTitle, description: siteDescription } = site; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const { title, description, tags } = Astro.props; | ||||||||||||||||||||
| const { title, description, tags, markdownNegotiation = false } = Astro.props; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const plainDescription = description | ||||||||||||||||||||
| ? (await plainText(description)).trim() | ||||||||||||||||||||
| : siteDescription; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const image = `${root}favicon.png`; | ||||||||||||||||||||
| --- | ||||||||||||||||||||
|
|
@@ -51,7 +57,7 @@ const image = `${root}favicon.png`; | |||||||||||||||||||
| <SEO | ||||||||||||||||||||
| charset="utf-8" | ||||||||||||||||||||
| title={title ?? siteTitle} | ||||||||||||||||||||
| description={description ?? siteDescription} | ||||||||||||||||||||
| description={plainDescription} | ||||||||||||||||||||
| {canonical} | ||||||||||||||||||||
| openGraph={{ | ||||||||||||||||||||
| basic: { | ||||||||||||||||||||
|
|
@@ -64,10 +70,20 @@ const image = `${root}favicon.png`; | |||||||||||||||||||
| twitter={{ | ||||||||||||||||||||
| site: root, | ||||||||||||||||||||
| title: title ?? siteTitle, | ||||||||||||||||||||
| description, | ||||||||||||||||||||
| description: plainDescription, | ||||||||||||||||||||
| image, | ||||||||||||||||||||
| card: "summary", | ||||||||||||||||||||
| }} | ||||||||||||||||||||
| extend={{ | ||||||||||||||||||||
| link: markdownNegotiation | ||||||||||||||||||||
| ? [ | ||||||||||||||||||||
| { | ||||||||||||||||||||
| rel: "alternate", | ||||||||||||||||||||
| href: `${canonical.origin}${canonical.pathname.replace(/\/$/, "")}.md`, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
|
Comment on lines
+80
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add MIME type to the markdown alternate link. For alternate-representation discovery, include Proposed fix {
rel: "alternate",
+ type: "text/markdown",
href: `${canonical.origin}${canonical.pathname.replace(/\/$/, "")}.md`,
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| ] | ||||||||||||||||||||
| : [], | ||||||||||||||||||||
| }} | ||||||||||||||||||||
| /> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <link | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fallback if stripped markdown description is empty.
After markdown removal and trim, the result can be empty; this would emit a blank meta description. Please fallback to
siteDescriptionin that case.Proposed fix
🤖 Prompt for AI Agents